﻿#include "mainwindow.h"
#include "ui_mainwindow.h"
using namespace std;
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{

    //新建进程类
    this->process = new QProcess;
    this->process->setProcessChannelMode(QProcess::MergedChannels);
    arg = "/usr/bin/mplayer";//设置mplayer播放器放到的位置

    ui->setupUi(this);

    // 获取当前工作目录
    currentPath = QDir::currentPath();
    //配置加载
    Config_Heavylod();
    //设置任务图标
    setWindowIcon(QIcon(":/new/prefix1/PageMain/log.ico"));
    //设置全屏
    this->setWindowFlags(Qt::FramelessWindowHint);
    //this->showFullScreen();
    //设置页面缩进
    m_eCurrentWindowState = Qt::WindowFullScreen;
    m_eOldWindowState = Qt::WindowNoState;
    installEventFilter(this);//事件过滤

    //创建Socket通讯
    ClientSocket = new QTcpSocket(this);
    connect(ClientSocket, &QTcpSocket::connected, this, &MainWindow::onConnected);//客户端连接成功
    connect(ClientSocket, &QTcpSocket::disconnected, this, &MainWindow::onDisconnected);//客户端断开连接
    connect(ClientSocket, &QTcpSocket::readyRead, this, &MainWindow::onReadyRead);//客户端接受读取数据
    connect(ClientSocket, static_cast<void(QAbstractSocket::*)(QAbstractSocket::SocketError)>(&QTcpSocket::error), this, &MainWindow::onError);//客户端错误信息 this, &MainWindow::onError);//客户端错误信息
    connect(&GlobalSignals::instance(), &GlobalSignals::SetLabel, this, &MainWindow::SetLabel,Qt::AutoConnection);//更新控件

    if(config.Model!="W7")
    {
        ui->pushButton_Door->hide();
        ui->label_Door->hide();
        //  ui->comboBox->removeItem(3);
    }

    //参数初始化
    StayScreen=0;//停留界面
    NewSerialportNum=-1;

    lastNum=0;
    IsHide=true;
    isOpen=false;
    isOpen1=false;
    IsLock=false;

    for(int i=1;i<=SYSTEMROW*SYSTEMLIST;++i)
    {
        //        layout[i]=nullptr;
        //        imageLabel1[i]=nullptr;
        //        imageLabel2[i]=nullptr;

        IdentNumber[i]="";
        IdentModel[i]="";
        IsUdisk[i]="";
        TemporaryPath[i]="";
        IsInitalize[i]=false;//是否初始化
        IsALLlist[i]=false;
        IsPriorlize[i]=false;//是否为优先口
        IsExtract[i]=false;
        IsBackdll[i]=-1;
        IsUpload[i]=false;
        Isbinding[i]=false;
    }

    //控件更新
    for(int i=1;i<=SYSTEMROW*SYSTEMLIST;++i)
    {
        if(IsAppointFirst&&AppointFirstNum==i)
        {
            emit GlobalSignals::instance().SetLabel(i,"优先"," ","禁用",0);
            emit GlobalSignals::instance().SetLabel(i+100,"优先","","禁用",0);
        }
        else{
            emit GlobalSignals::instance().SetLabel(i,"通用"," ","禁用",0);
            emit GlobalSignals::instance().SetLabel(i+100,"通用"," ","禁用",0);
        }
    }
    on_pushButton_2111_clicked();
    //加载上一次保存信息
    InterfaceMapInfo();
    // 创建一个悬浮容器的框架
    frame = new QFrame;
    frame->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
    frame->setAttribute(Qt::WA_TranslucentBackground);
    frame->setStyleSheet("QFrame { background-color: rgba(255, 255, 255, 120); }");

    // 创建一个垂直布局
    QVBoxLayout *layout = new QVBoxLayout(frame);

    // 创建一个列表视图
    QListView *listView = new QListView;

    // 创建一个字符串列表模型
    model = new QStringListModel;

    //Noticelist << "Item 1" << "Item 2" << "Item 3";


    // 将模型设置到列表视图中
    listView->setModel(model);
    // 连接itemClicked信号到槽函数
    connect(listView, &QListView::clicked, this, &MainWindow::onItemClicked);
    // 将列表视图添加到布局中
    layout->addWidget(listView);


    // 设置悬浮容器的大小和位置
    frame->resize(200, 150);
    frame->move(QApplication::desktop()->screenGeometry().width()-800,90/*QApplication::desktop()->rect().center() - frame->rect().center()*/);
    ui->TCL_01->setChecked(true);
    ui->TCL_02->setChecked(true);
    ui->TCL_03->setChecked(true);
    ui->TCL_06->setChecked(true);
    ui->TCL_07->setChecked(true);
    ui->TCL_1A->setChecked(true);
    ui->TCL_8A->setChecked(true);
    ui->TCL_R1->setChecked(true);
    ui->TCL_R2->setChecked(true);
    ui->TCL_T5->setChecked(true);
    ui->TCL_T6->setChecked(true);
    ui->TCL_T7->setChecked(true);
    ui->TCL_S1->setChecked(true);
    ui->TCL_S2->setChecked(true);
    ui->TCL_C2->setChecked(true);
    ui->TCL_C6->setChecked(true);
    ui->TCL_C7->setChecked(true);
    ui->TCL_C8->setChecked(true);
    ui->TCL_C9->setChecked(true);
    ui->TCL_C3->setChecked(true);

    //设置任务图标
    QString styleSheet = QString("QLabel { border-image: url('%1/%2') left bottom no-repeat; }").arg(currentPath).arg(config.Icon);
    ui->label_icon->setStyleSheet(styleSheet);
    //styleSheet = QString("font: 30pt '方正粗黑宋简体'; color: white;");
    //ui->label_name->setStyleSheet(styleSheet);
    styleSheet=QString(tr("版本号")+"：%1Type: %2_%3").arg(config.Version).arg(config.Model).arg(config.Datetime);
    //  ui->video_widget->setWindowIconText("111")
    ui->label_name->setText(config.Name);
    ui->label_version->setText(styleSheet);
    // 获取当前日期时间
    QDateTime currentDateTime = QDateTime::currentDateTime();

    // 计算一年前的日期时间
    QDateTime oneYearAgo = currentDateTime.addYears(-1);
    // 计算日期时间
    QDateTime YearAgo = currentDateTime.addYears(0);
    ui->dateTimeEdit->setDateTime(oneYearAgo);
    ui->dateTimeEdit_2->setDateTime(YearAgo);


    ui->dateTimeEdit_3->setDateTime(oneYearAgo);
    ui->dateTimeEdit_4->setDateTime(YearAgo);

    ui->row->setCurrentIndex(row-1);
    ui->list->setCurrentIndex(column-1);

    //开启后台心跳线程
    ui->stackedWidget->setCurrentWidget(ui->page);//切换页面
    ui->comboBox->setView(new QListView());//下拉样式要生效需要这句话
    ui->comboBox->setCurrentIndex(-1);

    //视频播发器初始化
    ui->tableWidget_3->horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed);//开启行
    ui->tableWidget_3->setEditTriggers(QAbstractItemView::NoEditTriggers);//设置不可编辑
    ui->tableWidget_3->horizontalHeader()->setSectionResizeMode(0,QHeaderView::Stretch);//设置第0行自适应
    ui->tableWidget_3->horizontalHeader()->setSectionResizeMode(1,QHeaderView::Stretch);
    ui->tableWidget_3->horizontalHeader()->setSectionResizeMode(2,QHeaderView::Stretch);//设置第0行自适应
    ui->tableWidget_3->horizontalHeader()->setSectionResizeMode(3,QHeaderView::Stretch);
    ui->tableWidget_3->setSelectionBehavior(QAbstractItemView::SelectRows);//每次都是选择一行
    ui->tableWidget_3->setSelectionMode(QAbstractItemView::SingleSelection);//只能选中一行
    ui->tableWidget_3->verticalHeader()->setVisible(false);
    //视频播发器初始化
    ui->tableWidget_2->horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed);//开启行
    ui->tableWidget_2->setEditTriggers(QAbstractItemView::NoEditTriggers);//设置不可编辑
    ui->tableWidget_2->horizontalHeader()->setSectionResizeMode(0,QHeaderView::Stretch);//设置第0行自适应
    ui->tableWidget_2->horizontalHeader()->setSectionResizeMode(1,QHeaderView::Stretch);
    ui->tableWidget_2->horizontalHeader()->setSectionResizeMode(2,QHeaderView::Stretch);
    ui->tableWidget_2->setSelectionBehavior(QAbstractItemView::SelectRows);//每次都是选择一行
    ui->tableWidget_2->setSelectionMode(QAbstractItemView::MultiSelection);//只能选中一行
    ui->tableWidget_2->verticalHeader()->setVisible(false);

    //视频播发器初始化
    ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed);//开启行
    ui->tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);//设置不可编辑
    ui->tableWidget->horizontalHeader()->setSectionResizeMode(0,QHeaderView::Stretch);//设置第0行自适应
    ui->tableWidget->horizontalHeader()->setSectionResizeMode(1,QHeaderView::Stretch);
    ui->tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);//每次都是选择一行
    ui->tableWidget->setSelectionMode(QAbstractItemView::SingleSelection);//只能选中一行
    ui->tableWidget->verticalHeader()->setVisible(false);

    //初始化公告
    QString announcementText = tr("这是公告内容...");
    // 关闭垂直滚动条
    //ui->textBrowser_message->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    ui->textBrowser->setPlainText(announcementText);
    // 设置样式
    // ui->textBrowser->setStyleSheet("QTextBrowser { color: #ECECEC; }");
    // 关闭垂直滚动条
    ui->textBrowser->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    ui->comboBox_num->setVisible(false);//隐藏
    ui->radioButton_without->setChecked(true);
    ui->widget_3->show();
    //ui->radioButton_resetradio->setChecked(false);
    ui->radioButton_appoint->setChecked(false);
    ui->widget_9->hide();
    ui->widget_72->hide();
    ui->widget_47->hide();
    ui->widget_48->hide();
    //播放器对象和视频小部件的初始化：
    pPlaye1 =new QMediaPlayer();
    pPlaylist1 =new QMediaPlaylist();
    //    pViedo =new QVideoWidget(ui->widget_55);
    //    //设置成标签大小
    //    pViedo->resize(ui->widget_55->size());
    //设备播放器的播放队列
    pPlaye1->setPlaylist(pPlaylist1);


    //播放器对象和视频小部件的初始化：
    pPlaye =new QMediaPlayer();
    pPlaylist =new QMediaPlaylist();
    //设备播放器的播放队列
    pPlaye->setPlaylist(pPlaylist);

    //设置音量为50
    this->process->write(QString("volume " + QString::number(50) +" 2\n").toUtf8());
    ui->horizontalSlider_2->setValue(50);
    connect(pPlaye,&QMediaPlayer::positionChanged,ui->horizontalSlider,&QSlider::setValue);
    connect(pPlaye,&QMediaPlayer::durationChanged,ui->horizontalSlider,[&](qint64 temp){
        ui->horizontalSlider->setRange(0,(int)temp);
    });
    // 更新当前播放时间和视频总时间
    QString scheduleText = "00:00:00/00:00:00" ;
    ui->schedulelabel->setText(scheduleText);
    ui->schedulelabel1->setText(scheduleText);

    //播放器对象和视频小部件的初始化：
    pPlayeAudio =new QMediaPlayer();
    pPlayAudiolist =new QMediaPlaylist();
    //设备播放器的播放队列
    pPlayeAudio->setPlaylist(pPlayAudiolist);

    MediaPlayer =new QMediaPlayer(this);
    // 更新当前播放时间和视频总时间
    QString scheduleAudioText = "00:00:00/00:00:00" ;
    ui->schedulelabel1->setText(scheduleAudioText);
    QVBoxLayout *containerLayout=new QVBoxLayout(ui->widget_69);
    viewer =new ImageViewer(ui->photo_widget);
    containerLayout->addWidget(viewer);



    //创建定时器
    timer = new QTimer();
    timer->setInterval(config.Sockettime.toInt());
    QObject::connect(timer, &QTimer::timeout, [&](){

        //        config.ReadInfo("config.ini","ServerAddress",ServerAddress);
        //        config.ReadInfo("config.ini","ServerPor",ServerPor);
        // 检查插座是否已连接或已连接
        if (ClientSocket->state() == QAbstractSocket::UnconnectedState) {
            // 套接字未连接，请启动连接
            ClientSocket->setProxy(QNetworkProxy::NoProxy);
            ClientSocket->connectToHost(config.ServerAddress, config.ServerPor.toUShort());
            config.WriteInfo("正在连接服务器");
        } else {
            // Socket is already connecting or connected, ignore the button click
            qDebug() << "连接正在进行，请先断开连接！";
            config.WriteInfo("连接正在进行，请先断开连接！");
        }
        // Check if the socket is already connecting or connected

    });
    // 启动定时器
    timer->start();
    connect(ui->label_icon, &ClickableLabel::clicked, this, &MainWindow::on_label_icon_Clicked);
    connect(ui->label_WOKIcon, &ClickableLabel::clicked, this, &MainWindow::on_label_WOKIcon_Clicked);
    // connect(ui->label_58, &ClickableLabel::twoclicked, this, &MainWindow::on_label_58_Clicked);
    connect(ui->label_version, &ClickableLabel::fiveClicked, this, &MainWindow::on_label_Clicked);
    // connect(ui->label_name, &ClickableLabel::fiveClicked, this, &MainWindow::on_label_Clicked);
    connect(ui->label_CALLIcon, &ClickableLabel::clicked, this, &MainWindow::on_label_CALLIcon_Clicked);
    // connect(ui->label_WOKIcon, &ClickableLabel::clicked, this, &MainWindow::on_label_WOKIcon_Clicked);

    connect(ui->textBrowser, &ClickableTextBrowser::clicked, this, &MainWindow::on_textBrowser_Clicked);
    connect(ui->lineEdit, &ClickableLineEdit::clicked, this, &MainWindow::on_lineEdit_Clicked);
    connect(ui->lineEdit_2, &ClickableLineEdit::clicked, this, &MainWindow::on_lineEdit_Clicked);
    connect(ui->dateTimeEdit_3, &ClickableDateTime::clicked, this, &MainWindow::on_lineEdit_Clicked);
    connect(ui->dateTimeEdit_4, &ClickableDateTime::clicked, this, &MainWindow::on_lineEdit_Clicked);
    connect(ui->dateTimeEdit, &ClickableDateTime::clicked, this, &MainWindow::on_lineEdit_Clicked);
    connect(ui->dateTimeEdit_2, &ClickableDateTime::clicked, this, &MainWindow::on_lineEdit_Clicked);
    connect(ui->lineEdit_UserID, &ClickableLineEdit::clicked, this, &MainWindow::on_lineEdit_UserID_Clicked);
    //线程回调主进程
    connect(ui->label_101, &ClickableLabel::clicked, this, &MainWindow::on_label_101_Clicked);
    connect(ui->label_102, &ClickableLabel::clicked, this, &MainWindow::on_label_102_Clicked);
    connect(ui->label_103, &ClickableLabel::clicked, this, &MainWindow::on_label_103_Clicked);
    connect(ui->label_104, &ClickableLabel::clicked, this, &MainWindow::on_label_104_Clicked);
    connect(ui->label_105, &ClickableLabel::clicked, this, &MainWindow::on_label_105_Clicked);
    connect(ui->label_106, &ClickableLabel::clicked, this, &MainWindow::on_label_106_Clicked);
    connect(ui->label_107, &ClickableLabel::clicked, this, &MainWindow::on_label_107_Clicked);
    connect(ui->label_108, &ClickableLabel::clicked, this, &MainWindow::on_label_108_Clicked);
    connect(ui->label_109, &ClickableLabel::clicked, this, &MainWindow::on_label_109_Clicked);
    connect(ui->label_110, &ClickableLabel::clicked, this, &MainWindow::on_label_110_Clicked);
    connect(ui->label_111, &ClickableLabel::clicked, this, &MainWindow::on_label_111_Clicked);
    connect(ui->label_112, &ClickableLabel::clicked, this, &MainWindow::on_label_112_Clicked);
    connect(ui->label_113, &ClickableLabel::clicked, this, &MainWindow::on_label_113_Clicked);
    connect(ui->label_114, &ClickableLabel::clicked, this, &MainWindow::on_label_114_Clicked);
    connect(ui->label_115, &ClickableLabel::clicked, this, &MainWindow::on_label_115_Clicked);
    connect(ui->label_116, &ClickableLabel::clicked, this, &MainWindow::on_label_116_Clicked);
    connect(ui->label_117, &ClickableLabel::clicked, this, &MainWindow::on_label_117_Clicked);
    connect(ui->label_118, &ClickableLabel::clicked, this, &MainWindow::on_label_118_Clicked);
    connect(ui->label_119, &ClickableLabel::clicked, this, &MainWindow::on_label_119_Clicked);
    connect(ui->label_120, &ClickableLabel::clicked, this, &MainWindow::on_label_120_Clicked);
    connect(ui->label_121, &ClickableLabel::clicked, this, &MainWindow::on_label_121_Clicked);
    connect(ui->label_122, &ClickableLabel::clicked, this, &MainWindow::on_label_122_Clicked);
    connect(ui->label_123, &ClickableLabel::clicked, this, &MainWindow::on_label_123_Clicked);
    connect(ui->label_124, &ClickableLabel::clicked, this, &MainWindow::on_label_124_Clicked);
    connect(ui->label_125, &ClickableLabel::clicked, this, &MainWindow::on_label_125_Clicked);

    connect(ui->label_101_1, &ClickableLabel::clicked, this, &MainWindow::on_label_101_Clicked);
    connect(ui->label_102_1, &ClickableLabel::clicked, this, &MainWindow::on_label_102_Clicked);
    connect(ui->label_103_1, &ClickableLabel::clicked, this, &MainWindow::on_label_103_Clicked);
    connect(ui->label_104_1, &ClickableLabel::clicked, this, &MainWindow::on_label_104_Clicked);
    connect(ui->label_105_1, &ClickableLabel::clicked, this, &MainWindow::on_label_105_Clicked);
    connect(ui->label_106_1, &ClickableLabel::clicked, this, &MainWindow::on_label_106_Clicked);
    connect(ui->label_107_1, &ClickableLabel::clicked, this, &MainWindow::on_label_107_Clicked);
    connect(ui->label_108_1, &ClickableLabel::clicked, this, &MainWindow::on_label_108_Clicked);
    connect(ui->label_109_1, &ClickableLabel::clicked, this, &MainWindow::on_label_109_Clicked);
    connect(ui->label_110_1, &ClickableLabel::clicked, this, &MainWindow::on_label_110_Clicked);
    connect(ui->label_111_1, &ClickableLabel::clicked, this, &MainWindow::on_label_111_Clicked);
    connect(ui->label_112_1, &ClickableLabel::clicked, this, &MainWindow::on_label_112_Clicked);
    connect(ui->label_113_1, &ClickableLabel::clicked, this, &MainWindow::on_label_113_Clicked);
    connect(ui->label_114_1, &ClickableLabel::clicked, this, &MainWindow::on_label_114_Clicked);
    connect(ui->label_115_1, &ClickableLabel::clicked, this, &MainWindow::on_label_115_Clicked);
    connect(ui->label_116_1, &ClickableLabel::clicked, this, &MainWindow::on_label_116_Clicked);
    connect(ui->label_117_1, &ClickableLabel::clicked, this, &MainWindow::on_label_117_Clicked);
    connect(ui->label_118_1, &ClickableLabel::clicked, this, &MainWindow::on_label_118_Clicked);
    connect(ui->label_119_1, &ClickableLabel::clicked, this, &MainWindow::on_label_119_Clicked);
    connect(ui->label_120_1, &ClickableLabel::clicked, this, &MainWindow::on_label_120_Clicked);
    connect(ui->label_121_1, &ClickableLabel::clicked, this, &MainWindow::on_label_121_Clicked);
    connect(ui->label_122_1, &ClickableLabel::clicked, this, &MainWindow::on_label_122_Clicked);
    connect(ui->label_123_1, &ClickableLabel::clicked, this, &MainWindow::on_label_123_Clicked);
    connect(ui->label_124_1, &ClickableLabel::clicked, this, &MainWindow::on_label_124_Clicked);
    connect(ui->label_125_1, &ClickableLabel::clicked, this, &MainWindow::on_label_125_Clicked);

    connect(ui->label_101_2, &ClickableLabel::clicked, this, &MainWindow::on_label_101_Clicked);
    connect(ui->label_102_2, &ClickableLabel::clicked, this, &MainWindow::on_label_102_Clicked);
    connect(ui->label_103_2, &ClickableLabel::clicked, this, &MainWindow::on_label_103_Clicked);
    connect(ui->label_104_2, &ClickableLabel::clicked, this, &MainWindow::on_label_104_Clicked);
    connect(ui->label_105_2, &ClickableLabel::clicked, this, &MainWindow::on_label_105_Clicked);
    connect(ui->label_106_2, &ClickableLabel::clicked, this, &MainWindow::on_label_106_Clicked);
    connect(ui->label_107_2, &ClickableLabel::clicked, this, &MainWindow::on_label_107_Clicked);
    connect(ui->label_108_2, &ClickableLabel::clicked, this, &MainWindow::on_label_108_Clicked);
    connect(ui->label_109_2, &ClickableLabel::clicked, this, &MainWindow::on_label_109_Clicked);
    connect(ui->label_110_2, &ClickableLabel::clicked, this, &MainWindow::on_label_110_Clicked);
    connect(ui->label_111_2, &ClickableLabel::clicked, this, &MainWindow::on_label_111_Clicked);
    connect(ui->label_112_2, &ClickableLabel::clicked, this, &MainWindow::on_label_112_Clicked);
    connect(ui->label_113_2, &ClickableLabel::clicked, this, &MainWindow::on_label_113_Clicked);
    connect(ui->label_114_2, &ClickableLabel::clicked, this, &MainWindow::on_label_114_Clicked);
    connect(ui->label_115_2, &ClickableLabel::clicked, this, &MainWindow::on_label_115_Clicked);
    connect(ui->label_116_2, &ClickableLabel::clicked, this, &MainWindow::on_label_116_Clicked);
    connect(ui->label_117_2, &ClickableLabel::clicked, this, &MainWindow::on_label_117_Clicked);
    connect(ui->label_118_2, &ClickableLabel::clicked, this, &MainWindow::on_label_118_Clicked);
    connect(ui->label_119_2, &ClickableLabel::clicked, this, &MainWindow::on_label_119_Clicked);
    connect(ui->label_120_2, &ClickableLabel::clicked, this, &MainWindow::on_label_120_Clicked);
    connect(ui->label_121_2, &ClickableLabel::clicked, this, &MainWindow::on_label_121_Clicked);
    connect(ui->label_122_2, &ClickableLabel::clicked, this, &MainWindow::on_label_122_Clicked);
    connect(ui->label_123_2, &ClickableLabel::clicked, this, &MainWindow::on_label_123_Clicked);
    connect(ui->label_124_2, &ClickableLabel::clicked, this, &MainWindow::on_label_124_Clicked);
    connect(ui->label_125_2, &ClickableLabel::clicked, this, &MainWindow::on_label_125_Clicked);

    connect(ui->label_101_3, &ClickableLabel::clicked, this, &MainWindow::on_label_101_Clicked);
    connect(ui->label_102_3, &ClickableLabel::clicked, this, &MainWindow::on_label_102_Clicked);
    connect(ui->label_103_3, &ClickableLabel::clicked, this, &MainWindow::on_label_103_Clicked);
    connect(ui->label_104_3, &ClickableLabel::clicked, this, &MainWindow::on_label_104_Clicked);
    connect(ui->label_105_3, &ClickableLabel::clicked, this, &MainWindow::on_label_105_Clicked);
    connect(ui->label_106_3, &ClickableLabel::clicked, this, &MainWindow::on_label_106_Clicked);
    connect(ui->label_107_3, &ClickableLabel::clicked, this, &MainWindow::on_label_107_Clicked);
    connect(ui->label_108_3, &ClickableLabel::clicked, this, &MainWindow::on_label_108_Clicked);
    connect(ui->label_109_3, &ClickableLabel::clicked, this, &MainWindow::on_label_109_Clicked);
    connect(ui->label_110_3, &ClickableLabel::clicked, this, &MainWindow::on_label_110_Clicked);
    connect(ui->label_111_3, &ClickableLabel::clicked, this, &MainWindow::on_label_111_Clicked);
    connect(ui->label_112_3, &ClickableLabel::clicked, this, &MainWindow::on_label_112_Clicked);
    connect(ui->label_113_3, &ClickableLabel::clicked, this, &MainWindow::on_label_113_Clicked);
    connect(ui->label_114_3, &ClickableLabel::clicked, this, &MainWindow::on_label_114_Clicked);
    connect(ui->label_115_3, &ClickableLabel::clicked, this, &MainWindow::on_label_115_Clicked);
    connect(ui->label_116_3, &ClickableLabel::clicked, this, &MainWindow::on_label_116_Clicked);
    connect(ui->label_117_3, &ClickableLabel::clicked, this, &MainWindow::on_label_117_Clicked);
    connect(ui->label_118_3, &ClickableLabel::clicked, this, &MainWindow::on_label_118_Clicked);
    connect(ui->label_119_3, &ClickableLabel::clicked, this, &MainWindow::on_label_119_Clicked);
    connect(ui->label_120_3, &ClickableLabel::clicked, this, &MainWindow::on_label_120_Clicked);
    connect(ui->label_121_3, &ClickableLabel::clicked, this, &MainWindow::on_label_121_Clicked);
    connect(ui->label_122_3, &ClickableLabel::clicked, this, &MainWindow::on_label_122_Clicked);
    connect(ui->label_123_3, &ClickableLabel::clicked, this, &MainWindow::on_label_123_Clicked);
    connect(ui->label_124_3, &ClickableLabel::clicked, this, &MainWindow::on_label_124_Clicked);
    connect(ui->label_125_3, &ClickableLabel::clicked, this, &MainWindow::on_label_125_Clicked);
    //ui->centralwidget->setContentsMargins(0, 0, 0, 0);
    //ui->stackedWidget->setCurrentWidget(ui->page_3);//切换页面
    if(config.PortNum.toInt()>25)
    {
        ui->pushButton_switch->show();
    }
    else
        ui->pushButton_switch->hide();

    ui->progressBar_111_1->setValue(0);
    ui->progressBar_101_1->setValue(0);

}
void MainWindow::Reconnect()
{
    Config_Heavylod();
    for(int i=1;i<=SYSTEMROW*SYSTEMLIST;++i)
    {
        if(IsAppointFirst&&AppointFirstNum==i)
        {
            emit GlobalSignals::instance().SetLabel(i,"优先"," ","禁用",0);
            emit GlobalSignals::instance().SetLabel(i+100,"优先","","禁用",0);
        }
        else{
            emit GlobalSignals::instance().SetLabel(i,"通用"," ","禁用",0);
            emit GlobalSignals::instance().SetLabel(i+100,"通用"," ","禁用",0);
        }
    }

    InterfaceMapInfo();
    ui->row->setCurrentIndex(row-1);
    ui->list->setCurrentIndex(column-1);

    switch (StayScreen) {
    case 0:
        ui->stackedWidget->setCurrentWidget(ui->page);//切换页面
        break;
    case 2:
        ui->stackedWidget->setCurrentWidget(ui->page_2);//切换页面
        break;
    case 3:
        ui->stackedWidget->setCurrentWidget(ui->page_3);//切换页面
        break;
    case 4:
        ui->stackedWidget->setCurrentWidget(ui->page_4);//切换页面
        break;
    case 5:
    {
        // 假设你的QTableWidget叫做tableWidget
        int rowCount = ui->tableWidget_2->rowCount();

        // 清空除第一行以外的数据
        for (int i = rowCount; i >= 0; --i) {
            ui->tableWidget_2->removeRow(i);
        }
        // 假设你的QTableWidget叫做tableWidget
        int rowCount3 = ui->tableWidget_3->rowCount();

        // 清空除第一行以外的数据
        for (int i = rowCount3; i >= 0; --i) {
            ui->tableWidget_3->removeRow(i);
        }
        ui->stackedWidget->setCurrentWidget(ui->page_5);//切换页面
        break;
    }
    case 6:
        ui->stackedWidget->setCurrentWidget(ui->page_6);//切换页面
        break;
    }


}
bool MainWindow::Config_Heavylod()
{
    if(!config.ReadInfo("config_label.ini"))
        return false;
    if(!config.ReadInfo("config.ini"))
        return false;

    // config.Write("D:\\Station\\R\\ver.txt",config.Version);
    if(config.Mode=="警情")
    {
        IsWarnInstance=true;
    }
    else
    {
        IsWarnInstance=false;
    }

    if(config.MaxUploadRate=="")//一个硬盘60MB/s
    {
        return false;
    }
    else
    {
        // 寻找第一个非数字的字符的位置
        int index = 0;
        while (index < config.MaxUploadRate.length() && config.MaxUploadRate.at(index).isDigit()) {
            index++;
        }

        // 使用left方法截取数字部分
        QString numericPart = config.MaxUploadRate.left(index);

        // 将字符串转换为整数
        UploadRate = numericPart.toInt();
        if(UploadRate<60)
        {
            config.WriteInfo("上传速率小于60");
            return false;
        }
    }
    if(config.prior==""||config.prior.toInt()<0)
    {
        IsAppointFirst=false;
        AppointFirstNum=-1;
        ui->radioButton_appoint->setChecked(false);
        ui->radioButton_without->setChecked(true);
    }
    else
    {
        AppointFirstNum=config.prior.toInt();
        ui->comboBox_num->setVisible(true);

        ui->comboBox_num->setCurrentIndex(AppointFirstNum);
        IsAppointFirst=true;

        IsPriorlize[AppointFirstNum]=true;
        ui->radioButton_appoint->setChecked(true);
        ui->radioButton_without->setChecked(false);
    }


    row=config.Row.toInt();
    column=config.List.toInt();
    Newrow=config.Row.toInt();
    Newcolumn=config.List.toInt();
    return true;
}
void MainWindow::onConnected()
{
    Prot=ClientSocket->localPort();
    qDebug() << "连接成功!";
    qDebug() << "请求端口： " <<Prot;
    config.WriteInfo(QString("已连接到服务器！,占用端口：%1").arg(Prot));
    timer->stop();
    // Perform any necessary operations after the connection is established
    // For example, you can send data to the server using m_tcpSocket->write()
}

// Slot called when the TCP connection is disconnected
void MainWindow::onDisconnected()
{
    qDebug() << "已断开与服务器的连接!";
    config.WriteInfo(QString("已断开与服务器的连接！"));
    ClientSocket->close();
    Prot=0;
    timer->start();
    StayScreen=0;
    // Perform any necessary cleanup or handling when the connection is closed
}
// Slot called when an error occurs during the TCP connection
void MainWindow::onError(QAbstractSocket::SocketError socketError)
{
    qDebug() << "出现错误：" << ClientSocket->errorString();
    config.WriteInfo(QString("出现错误：%1").arg(ClientSocket->errorString()));
    // Perform any necessary error handling or cleanup
}

// Slot called when data is received from the server
void MainWindow::onReadyRead()
{
    QByteArray data = ClientSocket->readAll();
    qDebug()<<"data="<<data;
    config.WriteInfo(QString("处理接收到的数据"));
    // 将 QByteArray 转换为 QString
    QString dataString = QString::fromUtf8(data);
    // 使用换行符分割JSON对象
    QStringList json_objects = dataString.split("end\n", QString::SkipEmptyParts);
    if (!json_objects.isEmpty()) {

        // 遍历选中的路径
        for (const QString& json_obj_str : json_objects) {
            // 解析JSON字符串
            qDebug()<<"json_obj_str="<<json_obj_str;
            QJsonDocument parsedJson = QJsonDocument::fromJson(json_obj_str.toUtf8());
            QJsonObject parsedObject = parsedJson.object();

            // 从解析后的JSON对象中获取值
            int ParentID = parsedObject["ParentID"].toInt();
            int SubID = parsedObject["SubID"].toInt();

            switch (SubID) {
            case MESSAGE_SYNCHRONIZATION://连接消息
            {
                config.WriteInfo(QString("重连初始化"));
                qDebug() << "重连初始化";
                Reconnect();
                timer->stop();
                break;
            }
            case UPDATE_CONTROL_S://修改ui
            {
                QJsonObject parsedAddress = parsedObject["Data"].toObject();
                // 从解析后的JSON对象中获取值
                int Display = parsedAddress["Display"].toInt();
                int SerialportNum = parsedAddress["SerialportNum"].toInt();
                QString Text = parsedAddress["Text"].toString();
                QString TextInfo = parsedAddress["TextInfo"].toString();
                int Textprompt = parsedAddress["Textprompt"].toInt();
                if(SerialportNum==CPU_UI||SerialportNum==MEMORY_UI||SerialportNum==DISK_UI||SerialportNum==NETWORK_UI)
                {

                    SetLabel(-1,Text.section(';',0,0),"","",-1);
                    SetLabel(-2,Text.section(';',1,1),"","",-1);
                    SetLabel(-3,Text.section(';',2,2),"","",-1);
                    SetLabel(-4,Text.section(';',3,3),"","",-1);
                    //SetLabel(-6,Text.section(';',4,4),"","",-1);

                    break;
                }
                if(SerialportNum==NOTICE_UI)
                {
                    if(Textprompt==0)
                    {
                        Notice.clear();
                    }
                    SetLabel(NOTICE_UI,Text,"","",-1);

                    break;
                }
                if(SerialportNum==BACKCONNECTION)
                {
                    if(Textprompt==0)
                    {
                        SetLabel(BACKCONNECTION,"","","",0);
                    }
                    else
                    {
                        SetLabel(BACKCONNECTION,"","","",1);
                    }
                    break;
                }
                if(0<SerialportNum<26)
                {
                    if(Textprompt==INITIALIZED)
                    {
                        IsALLlist[SerialportNum]=true;
                    }

                }
                if(100<SerialportNum<126)
                {
                    if(Textprompt==TURNINGTHEDIAL)
                    {
                        IsBackdll[SerialportNum-100]=0;

                    }
                    else if(Textprompt==TURNTABLESUCCESSFUL)
                    {
                        IsBackdll[SerialportNum-100]=1;
                    }
                    else if(Textprompt==TURNTABLEFAILED)
                    {
                        IsBackdll[SerialportNum-100]=-1;
                    }
                    else if(Textprompt==DISKMODE)
                    {
                        IsBackdll[SerialportNum-100]=2;
                        //                        config.WriteInfo(QString("处理接收到的数据TextInfo.section(';',1,1);%1").arg(TextInfo.section(';',1,1)));
                        //                        config.WriteInfo(QString("处理接收到的数据TextInfo.section(';',1,1);%1").arg(TextInfo.section(';',0,0)));
                        IdentNumber[SerialportNum-100]=TextInfo.section(';',1,1);
                        IsUdisk[SerialportNum-100]=TextInfo.section(';',0,0);

                        IdentElectricity[SerialportNum-100]=TextInfo.section(';',2,2).toInt();
                    } else if(Textprompt==IDLE)
                    {
                        IsBackdll[SerialportNum-100]=-1;
                        IdentNumber[SerialportNum-100]="";
                        IsUdisk[SerialportNum-100]="";
                        IsExtract[SerialportNum-100]=true;
                        IdentElectricity[SerialportNum-100]=0;
                    }

                    else if(Textprompt==UPLOADING)
                    {

                        //                        config.WriteInfo(QString("处理接收到的数据TextInfo.section(';',1,1);%1").arg(TextInfo.section(';',3,3)));
                        //                        config.WriteInfo(QString("处理接收到的数据TextInfo.section(';',1,1);%1").arg(TextInfo.section(';',2,2)));
                        //                        config.WriteInfo(QString("处理接收到的数据TextInfo.section(';',1,1);%1").arg(TextInfo.section(';',1,1)));
                        //                        config.WriteInfo(QString("处理接收到的数据TextInfo.section(';',1,1);%1").arg(TextInfo.section(';',0,0)));
                        unitName[SerialportNum-100]=TextInfo.section(';',3,3);
                        IdentNumber[SerialportNum-100]=TextInfo.section(';',2,2);
                        userNo[SerialportNum-100]=TextInfo.section(';',0,0);
                        userName[SerialportNum-100]=TextInfo.section(';',1,1);
                    }
                    else if(Textprompt==WARNBOUND)
                    {
                        //                        config.WriteInfo(QString("处理接收到的数据WARNBOUND.section(';',3,1);%1").arg(TextInfo.section(';',3,3)));
                        //                        config.WriteInfo(QString("处理接收到的数据WARNBOUND.section(';',2,1);%1").arg(TextInfo.section(';',2,2)));
                        //                        config.WriteInfo(QString("处理接收到的数据WARNBOUND.section(';',1,1);%1").arg(TextInfo.section(';',1,1)));
                        //                        config.WriteInfo(QString("处理接收到的数据WARNBOUND.section(';',0,1);%1").arg(TextInfo.section(';',0,0)));
                        unitName[SerialportNum-100]=TextInfo.section(';',3,3);
                        IdentNumber[SerialportNum-100]=TextInfo.section(';',2,2);
                        userNo[SerialportNum-100]=TextInfo.section(';',0,0);
                        userName[SerialportNum-100]=TextInfo.section(';',1,1);
                        Isbinding[SerialportNum-100]=true;
                    }

                }
                // Textprompt
                switch (Textprompt) {
                case UPLOADSTOP:
                {
                    emit GlobalSignals::instance().SetLabel(SerialportNum,Text,TextInfo,tr("停止上传"),Display);
                    break;
                }
                case UPLOADING:
                {

                    IsUpload[SerialportNum-100]=true;
                    SetLabel(SerialportNum,Text,QString(tr("产品序号")+":%3\n"+tr("用户编号")+":%1\n"+tr("用户名称")+":%2\n"+tr("单位名称")+":%4").arg(userNo[SerialportNum-100]).arg(userName[SerialportNum-100]).arg(IdentNumber[SerialportNum-100]).arg(unitName[SerialportNum-100]),tr("正在上传"),Display);
                    break;
                }
                case INITIALIZED:
                {
                    SetLabel(SerialportNum,Text,TextInfo,tr("已初始化"),Display);
                    break;
                }
                case INITIALIZING:
                {
                    SetLabel(SerialportNum,Text,TextInfo,tr("正在初始化"),Display);
                    break;
                }

                case TURNINGTHEDIAL:
                {
                    SetLabel(SerialportNum,Text,TextInfo,tr("正在转盘"),Display);
                    config.WriteInfo("设备接入");
                    break;
                }
                case TURNTABLESUCCESSFUL:
                {
                    SetLabel(SerialportNum,Text,TextInfo,tr("转盘成功"),Display);
                    config.WriteInfo("接入成功");
                    break;
                }
                case TURNTABLEFAILED:
                {
                    if(IsUdisk[SerialportNum-100]!="")
                        break;
                    else
                    {
                        IsDriverTime[SerialportNum-100] = QDateTime::currentMSecsSinceEpoch();
                        SetLabel(SerialportNum,Text,TextInfo,tr("等待磁盘"),Display);
                    }
                    break;
                }

                case DISKMODE:
                {
                    SetLabel(SerialportNum,Text,QString(tr("产品序号")+":%1\n"+tr("用户编号")+":\n"+tr("用户名称")+":\n"+tr("单位名称")+":")/*.arg(IsUdisk[SerialportNum-100])*/.arg(IdentNumber[SerialportNum-100]),tr("磁盘模式"),Display);
                    progressBar(SerialportNum,IdentElectricity[SerialportNum-100],1);
                    break;
                }

                case IDLE:
                {
                    IsUpload[SerialportNum-100]=false;
                    SetLabel(SerialportNum,""," ",tr("空闲"),Display);
                    qDebug()<<SerialportNum;
                    progressBar(SerialportNum,0,1);
                    progressBar(SerialportNum,0,0);
                    config.WriteInfo("空闲");
                    break;
                }
                case UPLOADCOMPLETED:
                {
                    IsUpload[SerialportNum-100]=false;
                    SetLabel(SerialportNum,Text,TextInfo,tr("上传完成"),Display);
                    progressBar(SerialportNum,100,0);
                    config.WriteInfo("上传完成");
                    break;
                }
                case UPLOADFAILED:
                {
                    SetLabel(SerialportNum,Text,TextInfo,tr("上传失败"),Display);
                    progressBar(SerialportNum,0,0);
                    config.WriteInfo("上传失败");
                    break;
                }
                case UNBOUND:
                {
                    SetLabel(SerialportNum,Text,TextInfo,tr("未绑定用户编号，请手动绑定"),Display);
                    break;
                }
                case WARNBOUND:
                {

                    SetLabel(SerialportNum,Text,QString(tr("产品序号")+":%1\n"+tr("用户编号")+":\n"+tr("用户名称")+":\n"+tr("单位名称")+":")/*.arg(IsUdisk[SerialportNum-100])*/.arg(IdentNumber[SerialportNum-100]),tr("已绑定用户编号，点击进入警情模式"),Display);

                    break;
                }
                case STATELESS:
                {
                    SetLabel(SerialportNum,Text,TextInfo,"",Display);
                    break;
                }
                case SCHEDULE:
                {
                    SetLabel(SerialportNum,"","",QString(tr("时间:")+Text+"  "+TextInfo+"  "+tr("已上传:")+"%1%").arg(Display),-1);
                    progressBar(SerialportNum,Display,0);
                    // ui->progressBar->setFormat(QString::fromLocal8Bit("当前进度为：%1%").arg(QString::number(11, 'f', 1)));
                    break;
                }
                }

                break;

            }
            case INTERFACE_MAPPING_S://接口映射登录
            {
                QJsonObject parsedAddress = parsedObject["Data"].toObject();
                // 从解析后的JSON对象中获取值
                int state = parsedAddress["state"].toInt();
                if(state==SUCCESS)
                {
                    if(config.PortNum.toInt()>25)
                    {
                        ui->pushButton_switch->show();
                    }
                    else
                        ui->pushButton_switch->hide();
                    StayScreen=3;//停留界面
                    ui->stackedWidget->setCurrentWidget(ui->page_3);//切换页面
                }
                else
                    QMessageBox::critical(nullptr, "错误", "账号密码错误.");
                break;
            }
            case INTERFACE_MAPPING_INFO_S://接口映射消息回复
            {
                QJsonObject parsedAddress = parsedObject["Data"].toObject();
                // 从解析后的JSON对象中获取值
                int Indet = parsedAddress["Indet"].toInt();
                row = parsedAddress["Row"].toInt();
                column = parsedAddress["Column"].toInt();
                Newrow=row;
                Newcolumn=column;
                AppointFirstNum=parsedAddress["AppointFirst"].toInt();
                AppointFirst=AppointFirstNum;
                for(int i=1;i<=SYSTEMROW*SYSTEMLIST;++i)
                {
                    IsALLlist[i]=false;
                    TemporaryPath[i]="";
                }
                calculateNumbers(row,column);

                //ResetTing();

                break;
            }
            case INTERFACE_MAPPING_SAVE_S://接口映射保存
            {
                QJsonObject parsedAddress = parsedObject["Data"].toObject();
                // 从解析后的JSON对象中获取值
                int state = parsedAddress["state"].toInt();
                if(state==SUCCESS)
                {
                    row =Newrow;
                    column=Newcolumn;
                    AppointFirstNum=AppointFirst;
                    StayScreen=0;//停留界面
                    qDebug()<<"page1";
                    ui->stackedWidget->setCurrentWidget(ui->page);//切换页面
                    for(int i=1;i<=SYSTEMROW*SYSTEMLIST;++i)
                    {
                        if(IsUdisk[i]!="")
                        {
                            SetLabel(i+100,"通用",QString("盘符路径:%1\n序列号:%2").arg(IsUdisk[i]).arg(IdentNumber[i]),"上传完成",-1);
                        }
                        else if(IsBackdll[i]!=-1)
                        {
                            if(IsBackdll[i]==0)
                                SetLabel(i+100,"通用","","进入转盘",-1);
                            else if(IsBackdll[i]==1)
                                SetLabel(i+100,"通用","","转盘成功",-1);
                            else if(IsBackdll[i]==2)
                                SetLabel(i+100,"通用","","磁盘模式",-1);
                            else if(IsBackdll[i]==3)
                                SetLabel(i+100,"通用","","正在转盘",-1);
                        }else if(IsInitalize[i])
                        {
                            qDebug() <<i<< "进入保存"<<IsALLlist[i];
                            if(IsALLlist[i]==true)
                            {
                                SetLabel(i+100,"通用"," ","空闲",1);
                            }else
                            {
                                SetLabel(i+100,"通用"," ","禁用",1);
                            }
                        }
                        else
                        {
                            SetLabel(i+100,"通用","","禁用",0);
                        }
                    }
                    if(IsAppointFirst&&AppointFirstNum>0)//如果存在优先口
                    {
                        IsPriorlize[AppointFirstNum]=true;
                        //ui->radioButton_resetradio->setChecked(false);
                        //                        ui->radioButton_appoint->setChecked(true);
                        //                        ui->radioButton_without->setChecked(false);
                        //                        if(config.UpdateRouteValueInfo("config_record.ini","Prior",QString("%1").arg(AppointFirstNum)))
                        //                        {

                        if(IsInitalize[AppointFirstNum])
                        {
                            if(IsALLlist[AppointFirstNum]==true)
                            {
                                SetLabel(AppointFirstNum+100,"优先"," ","空闲",1);
                            }else
                            {
                                SetLabel(AppointFirstNum+100,"优先"," ","禁用",1);
                            }
                            //SetLabel(AppointFirstNum,"优先","","",true);
                            //SetLabel(AppointFirstNum+100,"优先","","",1);
                        }
                        else
                        {
                            SetLabel(AppointFirstNum+100,"优先","","",0);
                        }

                        //}
                    }

                }
                else
                    QMessageBox::critical(nullptr, "错误", "保存失败.");
                break;
            }
            case  INTERFACE_MAPPING_EXIT_S://接口映射退出
            {
                calculateNumbers(row,column);
                AppointFirstNum=AppointFirst;
                if(AppointFirstNum>=0)
                {
                    ui->comboBox_num->setVisible(true);
                    //ui->radioButton_resetradio->setChecked(false);
                    ui->radioButton_appoint->setChecked(true);
                    ui->radioButton_without->setChecked(false);
                }
                else
                {
                    ui->comboBox_num->setVisible(false);
                    //ui->radioButton_resetradio->setChecked(false);
                    ui->radioButton_appoint->setChecked(false);
                    ui->radioButton_without->setChecked(true);
                }
                StayScreen=0;//停留界面
                qDebug()<<"page2";
                ui->stackedWidget->setCurrentWidget(ui->page);//切换页面
                break;
            }
            case  UPLOAD_S://接口映射退出
            {
                QJsonObject parsedAddress = parsedObject["Data"].toObject();
                // 从解析后的JSON对象中获取值
                int state = parsedAddress["state"].toInt();
                if(state==FAIL)
                {
                    QMessageBox::critical(nullptr, "错误", "账号或密码不能为空");
                }
                break;
            }
            case  INTERFACE_BACKGROUND_LOGIN_S://后台登录
            {
                QJsonObject parsedAddress = parsedObject["Data"].toObject();
                // 从解析后的JSON对象中获取值
                int state = parsedAddress["state"].toInt();
                if(state==FAIL)
                {
                    QMessageBox::critical(nullptr, "错误", "账号或密码不能为空");
                }
                else
                {
                    if(!IsClosingLogin)
                    {
                        IsClosingLogin=true;
                        dialog.Close();

                        //dialog.Delete();
                    }
                    //方法一
                    // QString Url = QString("http://127.0.0.1");
                    QDesktopServices::openUrl(QUrl(config.URL));

                    //方法二
                    //                    QString edgePath = "C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe";

                    //                    QStringList arguments;
                    //                    arguments << "--new-window" << URL;

                    //                    QProcess::startDetached(edgePath, arguments);
                }
                break;
            }
            case  INTERFACE_QUERY_S://数据查询
            {
                QJsonObject parsedAddress = parsedObject["Data"].toObject();
                // 从解析后的JSON对象中获取值
                int state = parsedAddress["state"].toInt();
                if(state==FAIL)
                {
                    QMessageBox::critical(nullptr, tr("错误"), tr("账号或密码错误"));
                }
                else if(state==SUCCESS)
                {
                    config.WriteInfo(QString("INTERFACE_QUERY_S=SUCCESS"));
                    StayScreen=2;//停留界面
                    // 获取当前日期时间
                    QDateTime currentDateTime = QDateTime::currentDateTime();

                    // 计算一年前的日期时间
                    QDateTime oneYearAgo = currentDateTime.addYears(-1);
                    // 计算日期时间
                    QDateTime YearAgo = currentDateTime.addYears(0);

                    ui->dateTimeEdit->setDateTime(oneYearAgo);
                    ui->dateTimeEdit_2->setDateTime(YearAgo);
                    ui->lineEdit->setText(NewUserID);
                    NewUserStatus=0;
                    ui->lineEdit_2->setText("");
                    ui->lineEdit->setReadOnly(true);
                    // 假设你的QTableWidget叫做tableWidget
                    int rowCount = ui->tableWidget->rowCount();

                    // 清空除第一行以外的数据
                    for (int i = rowCount; i >= 0; --i) {
                        ui->tableWidget->removeRow(i);
                    }
                    ui->stackedWidget->setCurrentWidget(ui->page_2);//切换页面
                    ui->widget_7->hide();
                }
                else if(state==SUCCESS_ADMIN)
                {
                    config.WriteInfo(QString("INTERFACE_QUERY_S=SUCCESS_ADMIN"));
                    StayScreen=2;//停留界面
                    // 获取当前日期时间
                    QDateTime currentDateTime = QDateTime::currentDateTime();

                    // 计算一年前的日期时间
                    QDateTime oneYearAgo = currentDateTime.addYears(-1);
                    // 计算日期时间
                    QDateTime YearAgo = currentDateTime.addYears(0);
                    ui->dateTimeEdit->setDateTime(oneYearAgo);
                    ui->dateTimeEdit_2->setDateTime(YearAgo);
                    ui->lineEdit->setText(NewUserID);
                    NewUserStatus=1;
                    ui->lineEdit_2->setText("");
                    ui->lineEdit->setReadOnly(false);
                    // 假设你的QTableWidget叫做tableWidget
                    int rowCount = ui->tableWidget->rowCount();

                    // 清空除第一行以外的数据
                    for (int i = rowCount; i >= 0; --i) {
                        ui->tableWidget->removeRow(i);
                    }
                    ui->stackedWidget->setCurrentWidget(ui->page_2);//切换页面
                    ui->widget_7->hide();
                }
                break;


            }
            case DEPARTMENT_FILE_QUERY_S:
            {
                Filetype.clear();
                DepartmentName.clear();
                BindList.clear();
                StayScreen=5;
                // 假设你的QTableWidget叫做tableWidget
                int rowCount = ui->tableWidget_2->rowCount();

                // 清空除第一行以外的数据
                for (int i = rowCount; i >= 0; --i) {
                    ui->tableWidget_2->removeRow(i);
                }
                // 假设你的QTableWidget叫做tableWidget
                int rowCount3 = ui->tableWidget_3->rowCount();

                // 清空除第一行以外的数据
                for (int i = rowCount3; i >= 0; --i) {
                    ui->tableWidget_3->removeRow(i);
                }
                ui->stackedWidget->setCurrentWidget(ui->page_5);//切换页面
                b(IsUdisk[SerialPort]);

                ui->comboBox_department->clear();
                // Add new items
                ui->comboBox_department->addItem("");
                ui->comboBox_filetype->clear();
                // Add new items
                ui->comboBox_filetype->addItem("");
                DepartmentName.clear();
                QJsonObject parsedAddress = parsedObject["Data"].toObject();
                // 从QJsonObject中获取特定字段的值
                // Extract values from the "data" object
                QJsonArray category_list = parsedAddress["category_list"].toArray();
                QJsonArray unitList = parsedAddress["unit_list"].toArray();

                for (const QJsonValue& category : category_list) {
                    QJsonObject categoryObject = category.toObject();
                    DepartmentInfo DInfo;
                    DInfo.ID = categoryObject["ID"].toString();
                    DInfo.Name = categoryObject["Name"].toString();

                    Filetype.push_back(DInfo);
                    ui->comboBox_filetype->addItem(DInfo.Name);
                    config.WriteInfo(QString("categoryId:=%1").arg(DInfo.Name));
                    // Process or store the category data as needed
                }
                // Now, you can iterate over the arrays to access individual elements
                for (const QJsonValue& category : unitList) {
                    QJsonObject categoryObject = category.toObject();
                    DepartmentInfo DInfo;
                    DInfo.ID = categoryObject["ID"].toString();
                    DInfo.Name = categoryObject["Name"].toString();
                    DepartmentName.push_back(DInfo);
                    ui->comboBox_department->addItem(DInfo.Name);
                    config.WriteInfo(QString("categoryId:=%1,categoryName:=%2").arg(DInfo.ID).arg(DInfo.Name));
                    // Process or store the category data as needed
                }

                break;
            }
            case POLICE_SITUATION_INQUIRY_S:
            {

                PoliceInfo.clear();
                QJsonObject parsedAddress = parsedObject["Data"].toObject();
                // 从QJsonObject中获取特定字段的值
                // Extract values from the "data" object
                QJsonArray jsonPoliceInfo = parsedAddress["jsonPoliceInfo"].toArray();
                //    QJsonArray unitList = parsedAddress["unit_list"].toArray();

                for (const QJsonValue& category : jsonPoliceInfo) {
                    QJsonObject categoryObject = category.toObject();
                    WarnInfo WInfo;
                    WInfo.case_number=categoryObject["case_number"].toString();
                    WInfo.unit_number=categoryObject["unit_number"].toString();
                    WInfo.case_desc=categoryObject["case_desc"].toString();
                    WInfo.happen_address=categoryObject["happen_address"].toString();
                    WInfo.call_police_time=categoryObject["call_police_time"].toString();
                    WInfo.alarm_time_text=categoryObject["alarm_time_text"].toString();
                    WInfo.trafficCaseTable=categoryObject["trafficCaseTable"].toString();
                    PoliceInfo.push_back(WInfo);
                    // Process or store the category data as needed
                }

                int i=0;
                //                for(int j=0;j<lastNum;j++)
                //                {
                //                    delete item[j];
                //                    delete item1[j];
                //                    delete item2[j];
                //                    delete item3[j];
                //                }

                //遍历所有控件状态
                for (auto& deviceInfo : PoliceInfo) {
                    int nCount=ui->tableWidget_3->rowCount();
                    if(nCount<=i)
                    {
                        ui->tableWidget_3->insertRow(i);
                    }
                    item[i]= new QTableWidgetItem(QString("%1").arg(deviceInfo.case_number));
                    ui->tableWidget_3->setItem(i,0,item[i]);
                    item1[i]= new QTableWidgetItem(QString("%1").arg(deviceInfo.call_police_time));
                    ui->tableWidget_3->setItem(i,1,item1[i]);
                    item2[i]= new QTableWidgetItem(QString("%1").arg(deviceInfo.happen_address));
                    ui->tableWidget_3->setItem(i,2,item2[i]);
                    item3[i]= new QTableWidgetItem(QString("%1").arg(deviceInfo.case_desc));
                    ui->tableWidget_3->setItem(i,3,item3[i]);
                    item4[i]= new QTableWidgetItem(QString("否"));
                    ui->tableWidget_3->setItem(i,4,item4[i]);
                    i++;

                }
                lastNum=i;
                break;
            }
            case POLICE_SITUATION_UPLOAD_S:
            {
                ui->stackedWidget->setCurrentWidget(ui->page);//切换页面
                break;
            }
            case LOCK_LABEL_S:
            {
                QJsonObject parsedAddress = parsedObject["Data"].toObject();
                // 从解析后的JSON对象中获取值
                int state = parsedAddress["state"].toInt();
                if(state==SUCCESS)
                {
                    IsLock = !IsLock;
                }
                else
                {
                    QMessageBox::critical(nullptr, tr("错误"), tr("账号或密码错误"));
                }
                break;
            }
            case INTERFACE_SWITCH_S:
            {
                config.WriteInfo("INTERFACE_SWITCH_C");
                config.WriteInfo(QString("Newrow=%1,Newcolumn=%2").arg(Newrow).arg(Newcolumn));
                for (int row = 1; row <= Newrow; row++) {
                    for (int col = 1; col <= Newcolumn; col++) {
                        int number = (row - 1) * 5 + col;  // 计算当前格子的数字
                        //IsInitalize[number]=true;

                        SetLabel(number,"","","未初始化",1);
                    }
                }
                SetLabel(1,"","","正在初始化",1);
                ui->pushButton_switch->hide();
                break;
            }
            default:
            {
                break;
            }

            }
        }
    }
    // Process the received data as needed
}





//下拉选择
void MainWindow::on_comboBox_textActivated(const QString &arg1)
{
    ui->comboBox->setCurrentIndex(-1);
    if(arg1=="退出")
    {
        // 要结束的进程名
        QString killCommand = "pkill Station_SERVER"; // 创建一个QProcess对象
        QProcess process; // 执行结束进程的命令
        process.start(killCommand); // 等待进程完成
        process.waitForFinished();
        close();//关闭窗口
    }
    else if(arg1=="接口映射")
    {
        //Startkeyboard();
        QString UserID="",Password="";

        if(!OpenLoginDialog(UserID,Password,"",5,1))//登录
        {
            //QMessageBox::information(nullptr, "提示", QString("%1.密码或用户名错误！").arg(3));
            //handlePrint("密码或用户名错误！");
            //return;
        }


        //            threadinfo.Indet=TNOTICE;
        //            threadinfo.SerialportNum=0;
        //            threadinfo.UserID="";
        //            threadinfo.Serialnumber="";//序列号
        //            threadinfo.Device="";//盘符
        //            // threadinfo.message=nullptr;//公告文本
        //            threadinfo.lpdb=nullptr;//公告文本//公告文本
        //            threadinfo.Identnumber="";//标识号
        //            threadHeartbeat->PushTask(threadinfo,true);

        //InterfaceMapInfo();

    }
    else if(arg1=="设置管理")
    {
        //        config.ReadInfo("config.ini","URL",URL);//后台地址
        //        config.ReadInfo("config.ini","PortNum",PortNum);//端口数量
        //        config.ReadInfo("config.ini","DeleteFiles",DeleteFiles);//上传后是否删除音视频文件
        //        config.ReadInfo("config.ini","MUI",MUI);//语言包
        //        config.ReadInfo("config.ini","TheLocalKey",TheLocalKey);//账号
        //        config.ReadInfo("config.ini","TheLocalKeyPDW",TheLocalKeyPDW);//密码
        //        config.ReadInfo("config.ini","NetworkName",NetworkName);//网络名称
        //        config.ReadInfo("config.ini","Ttime",Ttime);//后台心跳时间1分钟
        //        config.ReadInfo("config.ini","ServerAddress",ServerAddress);//服务IP
        //        config.ReadInfo("config.ini","ServerPor",ServerPor);//服务端口
        //        config.ReadInfo("config.ini","Sockettime",Sockettime);//服务链接间隔时间
        //        config.ReadInfo("config.ini","BackgroundVersion",BackgroundVersion);//后台版本
        //        config.ReadInfo("config.ini","UploadUrl",UploadUrl);//上传路径
        //        config.ReadInfo("config.ini","MountUrl",MountUrl);//挂载根目录
        //        config.ReadInfo("config.ini","Mode",Mode);//上传模式
        //        config.ReadInfo("config.ini","MemoryLack",MemoryLack);//内存不足报警
        //        config.ReadInfo("config.ini","CPULack",CPULack);//CPU不足报警
        //        config.ReadInfo("config.ini","Camera",Camera);//是否启动摄像头
        //        config.ReadInfo("config.ini","FingerPrint",FingerPrint);//是否启动指纹识别
        //        config.ReadInfo("config.ini","FaceRecognition",FaceRecognition);//是否启动人脸识别


        //        ui->label_ram->setText(MemoryLack);
        //        ui->label_cpu->setText(CPULack);
        //        ui->label_backversion->setText(BackgroundVersion);
        //        ui->label_accountnum->setText(TheLocalKey);
        //        ui->label_passwd->setText(TheLocalKeyPDW);
        //        ui->label_languagepack->setText(MUI);
        //        ui->label_backurl->setText(URL);
        //        ui->label_multidiskmount->setText(MountUrl);
        //        ui->label_camera->setText(Camera);
        //        ui->label_fingermark->setText(FingerPrint);
        //        ui->label_face->setText(FaceRecognition);
        //        ui->label_deletevideo->setText(DeleteFiles);
        //        StayScreen=6;//停留界面
        //        ui->stackedWidget->setCurrentWidget(ui->page_6);//切换页面
        //        // 获取应用程序的当前目录
        //        QString currentDir = QCoreApplication::applicationDirPath();
        //        // 设置初始路径
        //        QString initialPath = "/config.ini";
        //        // 拼接完整的文件路径
        //        QString filePath = currentDir + "/" + initialPath;

        //        // 使用QDesktopServices打开文件
        //        QUrl fileUrl = QUrl::fromLocalFile(filePath);
        //        QDesktopServices::openUrl(fileUrl);
    }
    else if(arg1=="视频播放")
    {
        StayScreen=2;//停留界面
        ui->stackedWidget->setCurrentWidget(ui->page_2);//切换页面
    }
    else if(arg1=="后台登录")
    {
        // Startkeyboard();
        QString UserID="",Password="";
        if(!OpenLoginDialog(UserID,Password,"",1,1))//登录
        {
            handlePrint("密码错误");
            return;
        }


    }
    else if(arg1=="系统重启")
    {
        // restartSystem();
    }
    else if(arg1=="兼容设置")
    {
        //  config.UpdateRouteValueInfo("config_record.ini","TCL_C8",QString("%1").arg(ui->TCL_C8->isChecked()));
        StayScreen=4;//停留界面
        ui->stackedWidget->setCurrentWidget(ui->page_4);//切换页面
    }
    else if(arg1=="警情界面")
    {
        StayScreen=5;
        ui->stackedWidget->setCurrentWidget(ui->page_5);//切换页面
        b("/media/tcl/949E-DEED");
        QJsonObject jsonObject;
        Send(ACQUISITION_STATION,POLICE_MODE_C,jsonObject);
    }
    else{
        close();//关闭窗口
    }

    return;
}
//打开文件按钮
void MainWindow::on_pushButton_2_clicked()
{
    QFileDialog fileDialog(this);
    fileDialog.setAcceptMode(QFileDialog::AcceptOpen);
    //将文件对话框的标题设置为“打开文件”。
    fileDialog.setWindowTitle(tr("Open Files"));
    //中检索支持的 MIME 类型的列表
    QStringList supportedMimeTypes = pPlaye->supportedMimeTypes();
    // 设置文件选择模式为多选模式
    fileDialog.setFileMode(QFileDialog::ExistingFiles);
    fileDialog.setDirectory(QStandardPaths::standardLocations(QStandardPaths::MoviesLocation).value(0, QDir::homePath()));
    if (fileDialog.exec() == QDialog::Accepted)
    {//获取用户选择的文件的路径列表。
        QStringList selectedFiles = fileDialog.selectedFiles();
        if (!selectedFiles.isEmpty()) {
            //把选择的加入列表
            ui->listWidget->addItems(selectedFiles);
            // 遍历选中的路径
            for (const QString& filePath : selectedFiles) {
                qDebug() << filePath;
                QUrl url(filePath);
                QStringList videoFormats = {"mp4", "avi", "mkv", "mov"};
                QString fileExtension = url.fileName().section('.', -1);
                if (videoFormats.contains(fileExtension, Qt::CaseInsensitive)) { // 判断是否为视频
                    pPlaylist->addMedia(url); // 加入到播放列表中
                }
            }
        }
    }
    int item = pPlaylist->mediaCount(); // Get the number of media items in the playlist

    for (int i = 0; i < item; i++) {
        QMediaContent media = pPlaylist->media(i); // Get the media item at the specified index
        QUrl url = media.request().url(); // Get the URL of the media item

        // Output the URL or perform any desired operations
        qDebug() << url;
    }

    isOpen=true;
}
//播放视频按钮
void MainWindow::play(QString fileName,unsigned int winId)
{

    QStringList arg1;
    this->process->kill();
    this->process=new QProcess;
    arg1 << fileName;
    arg1 << "-slave";//默认情况下，mplayer接受键盘的命令，而"-slave"使其不再接受键盘事件，而是作为后台程序运行，
    //接受以“\n”结束的命令控制，这样我们可以在进程中给他发送命令，而不需要操作键盘了.
    arg1 << "-quiet"; //尽可能的不打印播放信息
    arg1 << "-zoom"; //视频居中，四周黑条，全屏播放

    arg1 << "-wid" << QString::number(winId);
    // "-wid <窗口标识>" 是指让MPlayer依附于那个窗口，
    //ui->widget->winId() 这个指令就是用来获取widget的标识码 ,
    //这样视频播放的时候，就在这个部件里播放，相当于给他固定起来。

    connect(this->process,SIGNAL(readyReadStandardOutput()),this,SLOT(dataReceive()));
    this->process->start(arg,arg1);   //开始播放进程

    this->setWindowTitle(fileName);//设置当前播放的视频的标题名称
    //获取播放的图标样式
    // QPixmap pixmap;
    //pixmap.load("/home/llw/Desktop/Qt-mplayer-master/images/voice.png");
    //QPixmap pixmap4;
    //pixmap4.load("/home/llw/Desktop/Qt-mplayer-master/images/stop.png");
    //ui->play_on_pushButton_bofang_clicked->setFixedSize(pixmap.width(),pixmap.height());
    // ui->startButton->setIcon(pixmap4);
    //ui->startButton->setIconSize(QSize(pixmap.width(),pixmap.height()));
    //    ui->pushButton_zantingorstart->setToolTip("暂停播放视频");
    //    ui->pushButton_zantingorstart->show();//显示暂停播放之后的内容

}
//接收视频信息(当前时间，总时间，进度)，并显示的函数
void MainWindow::dataReceive()
{

    //调用进程去控制命令和输出视频总时间和视频进度的百分比
    this->process->write("get_time_length\n");
    this->process->write("get_time_pos\n");
    this->process->write("get_percent_pos\n");
    while(this->process->canReadLine())
    {
        QByteArray b(this->process->readLine());
        b.replace(QByteArray("\n"), QByteArray(""));
        QString s(b);

        if (b.startsWith("ANS_LENGTH"))  //输出视频总时间
        {
            int totalTimeNum = s.mid(11).toFloat();
            int sec = 0, min = 0, hour = 0;
            if(totalTimeNum < 60)
            {
                sec = totalTimeNum;
                min = 0;
                hour= 0;
            }
            if(totalTimeNum >= 60 && totalTimeNum <3600)
            {
                sec = totalTimeNum%60;
                min = totalTimeNum/60;
                hour= 0;
            }
            if(totalTimeNum > 3600)
            {
                sec = totalTimeNum%60;
                min = totalTimeNum/60%60;
                hour= totalTimeNum/3600;
            }

            QString totalTime = QString("%1:%2:%3").arg(hour).arg(min).arg(sec);  //标准格式输出时间
            // ui->schedulelabel->setText(totalTime);
            ui->horizontalSlider->setRange(0,totalTimeNum);//播放进度条的移动

            //ui->schedulelabel1->setText(totalTime);
            ui->horizontalSlider_audio1->setRange(0,totalTimeNum);//播放进度条的移动
        }

        else if (b.startsWith("ANS_TIME_POSITION"))  //输出视频当前时间
        {
            int currentTimeNum = s.mid(18).toFloat();

            if(currentTimeNum!=currentTimeString)
            {
                qDebug()<<currentTimeNum;
                currentTimeString=currentTimeNum;
                int sec = 0, min = 0, hour = 0;
                if(currentTimeNum < 60)
                {
                    sec = currentTimeNum;
                    min = 0;
                    hour= 0;
                }
                else if(currentTimeNum >= 60 && currentTimeNum <3600)
                {
                    sec = currentTimeNum%60;
                    min = currentTimeNum/60;
                    hour= 0;
                }
                else if(currentTimeNum > 3600)
                {
                    sec = currentTimeNum%60;
                    min = currentTimeNum/60%60;
                    hour= currentTimeNum/3600;
                }
                ui->schedulelabel->setText(QString("%1:%2:%3").arg(hour).arg(min).arg(sec));
                ui->horizontalSlider->setValue(currentTimeNum);//显示当前暂停的时候进度条的移动偏移量

                //                ui->schedulelabel1->setText(QString("%1:%2:%3").arg(hour).arg(min).arg(sec));

                //                ui->horizontalSlider_audio1->setValue(currentTimeNum);//播放进度条的移动

            }
        }
        //        else if(b.startsWith("ANS_PERCENT_POSITION"))
        //        {
        //             // qDebug()<<3;

        //            //QString currentPercent = s.mid(21);
        //           // ui->label_precentlable->setText(currentPercent+"%");//视频播放进度百分比
        //        }
    }
}

void MainWindow::progressBar(int Index,int Valer,int variable)
{
    qDebug()<<"progressBar"<<Index<<Valer<<variable;
    switch (Index) {
    case 101:
    {
        if(variable==0)
        {
            ui->progressBar_101->setValue(Valer);
        }
        else if(variable==1)
        {

            qDebug()<<"progressBar,variable";
            ui->progressBar_101_1->setValue(Valer);
        }
        else
        {

        }
        break;
    }
    case 102:
    {
        if(variable==0)
        {
            ui->progressBar_102->setValue(Valer);
        }
        else if(variable==1)
        {
            ui->progressBar_102_1->setValue(Valer);
        }
        break;
    }
    case 103:
    {
        if(variable==0)
        {
            ui->progressBar_103->setValue(Valer);
        }
        else if(variable==1)
        {
            ui->progressBar_103_1->setValue(Valer);
        }
        break;
    }
    case 104:
    {
        if(variable==0)
        {
            ui->progressBar_104->setValue(Valer);
        }
        else if(variable==1)
        {
            ui->progressBar_104_1->setValue(Valer);
        }
        break;
    }
    case 105:
    {
        if(variable==0)
        {
            ui->progressBar_105->setValue(Valer);
        }
        else if(variable==1)
        {
            ui->progressBar_105_1->setValue(Valer);
        }
        break;
    }
    case 106:
    {
        if(variable==0)
        {
            ui->progressBar_106->setValue(Valer);
        }
        else if(variable==1)
        {
            ui->progressBar_106_1->setValue(Valer);
        }
        break;
    }
    case 107:
    {
        if(variable==0)
        {
            ui->progressBar_107->setValue(Valer);
        }
        else if(variable==1)
        {
            ui->progressBar_107_1->setValue(Valer);
        }
        break;
    }
    case 108:
    {
        if(variable==0)
        {
            ui->progressBar_108->setValue(Valer);
        }
        else if(variable==1)
        {
            ui->progressBar_108_1->setValue(Valer);
        }
        break;
    }
    case 109:
    {
        if(variable==0)
        {
            ui->progressBar_109->setValue(Valer);
        }
        else if(variable==1)
        {
            ui->progressBar_109_1->setValue(Valer);
        }
        break;
    }
    case 110:
    {
        if(variable==0)
        {
            ui->progressBar_110->setValue(Valer);
        }
        else if(variable==1)
        {
            ui->progressBar_110_1->setValue(Valer);
        }
        break;
    }
    case 111:
    {
        if(variable==0)
        {
            ui->progressBar_111->setValue(Valer);
        }
        else if(variable==1)
        {
            ui->progressBar_111_1->setValue(Valer);
        }
        break;
    }
    case 112:
    {if(variable==0)
        {
            ui->progressBar_112->setValue(Valer);
        }
        else if(variable==1)
        {
            ui->progressBar_112_1->setValue(Valer);
        }
        break;
    }
    case 113:
    {if(variable==0)
        {
            ui->progressBar_113->setValue(Valer);
        }
        else if(variable==1)
        {
            ui->progressBar_113_1->setValue(Valer);
        }
        break;
    }

    case 114:
    {if(variable==0)
        {
            ui->progressBar_114->setValue(Valer);
        }
        else if(variable==1)
        {
            ui->progressBar_114_1->setValue(Valer);
        }
        break;
    }
    case 115:
    {if(variable==0)
        {
            ui->progressBar_115->setValue(Valer);
        }
        else if(variable==1)
        {
            ui->progressBar_115_1->setValue(Valer);
        }
        break;
    }
    case 116:
    {if(variable==0)
        {
            ui->progressBar_116->setValue(Valer);
        }
        else if(variable==1)
        {
            ui->progressBar_116_1->setValue(Valer);
        }
        break;
    }
    case 117:
    {if(variable==0)
        {
            ui->progressBar_117->setValue(Valer);
        }
        else if(variable==1)
        {
            ui->progressBar_117_1->setValue(Valer);
        }
        break;
    }
    case 118:
    {if(variable==0)
        {
            ui->progressBar_118->setValue(Valer);
        }
        else if(variable==1)
        {
            ui->progressBar_118_1->setValue(Valer);
        }
        break;
    }
    case 119:
    {if(variable==0)
        {
            ui->progressBar_119->setValue(Valer);
        }
        else if(variable==1)
        {
            ui->progressBar_119_1->setValue(Valer);
        }
        break;
    }
    case 120:
    {if(variable==0)
        {
            ui->progressBar_120->setValue(Valer);
        }
        else if(variable==1)
        {
            ui->progressBar_120_1->setValue(Valer);
        }
        break;
    }

    case 121:
    {if(variable==0)
        {
            ui->progressBar_121->setValue(Valer);
        }
        else if(variable==1)
        {
            ui->progressBar_121_1->setValue(Valer);
        }
        break;
    }
    case 122:
    {if(variable==0)
        {
            ui->progressBar_122->setValue(Valer);
        }
        else if(variable==1)
        {
            ui->progressBar_122_1->setValue(Valer);
        }
        break;
    }
    case 123:
    {if(variable==0)
        {
            ui->progressBar_123->setValue(Valer);
        }
        else if(variable==1)
        {
            ui->progressBar_123_1->setValue(Valer);
        }
        break;
    }
    case 124:
    {if(variable==0)
        {
            ui->progressBar_124->setValue(Valer);
        }
        else if(variable==1)
        {
            ui->progressBar_124_1->setValue(Valer);
        }
        break;
    }
    case 125:
    {if(variable==0)
        {
            ui->progressBar_125->setValue(Valer);
        }
        else if(variable==1)
        {
            ui->progressBar_125_1->setValue(Valer);
        }
        break;
    }
    default:
    {
        break;
    }
    }
}
//播放按钮
void MainWindow::on_pushButton_3_clicked()
{

    //    if(ui->listWidget->currentRow() == 0)//当光标在第一个文件时，点击上一个光标移动到最下面的文件，不播放，在列表上调整按钮控制上下播放
    //    {
    //        ui->listWidget->setCurrentRow(ui->listWidget->count()-1);
    //    }

    //    else
    //    {

    //        ui->listWidget->setCurrentRow(ui->listWidget->currentRow()-1);
    //        play(ui->listWidget->currentItem()->text());
    //        //调整上一个视频按钮的样式帖图，改变样式
    //        //QPixmap pixmap;
    //        //pixmap.load("/home/llw/Desktop/Qt-mplayer-master/images/voice.png");
    //        //QPixmap pixmap4;
    //        //pixmap4.load("/home/llw/Desktop/Qt-mplayer-master/images/stop.png");
    //        //ui->startButton->setFixedSize(pixmap.width(),pixmap.height());
    //        //ui->startButton->setIcon(pixmap4);
    //        //ui->startButton->setIconSize(QSize(pixmap.width(),pixmap.height()));
    //        ui->pushButton_zantingorstart->setToolTip("暂停播放");
    //        ui->pushButton_zantingorstart->show();//显示暂停播放上一个视频的内容
    //    }
    int itemCount = ui->listWidget->count();//获取数量
    int nextVideoIndex = -1;
    for (int i = 0; i < itemCount; i++) {
        QListWidgetItem* item = ui->listWidget->item(i);
        QString path = item->text(); // 获取路径文本
        QUrl url(path);
        QStringList videoFormats = {"mp4", "avi", "mkv", "mov"};
        QString fileExtension = url.fileName().section('.', -1);
        if (videoFormats.contains(fileExtension, Qt::CaseInsensitive)) {// 判断是否为视频
            nextVideoIndex = i;
            break;
        }
    }
    QList<QListWidgetItem*> selectedItems = ui->listWidget->selectedItems();
    if (!selectedItems.isEmpty()) {
        foreach (QListWidgetItem* item, selectedItems) {
            QString path = item->text(); // Assuming the path is stored as text in each item
            //选中的音频播放加入到队列中
            QUrl url(path);

            QStringList videoFormats = {"mp4", "avi", "mkv", "mov"}; // Add more video formats if needed
            QString fileExtension = url.fileName().section('.', -1);
            if (videoFormats.contains(fileExtension, Qt::CaseInsensitive)) {
                int itempPlay = pPlaylist->mediaCount(); // Get the number of media items in the playlist
                for (int j = 0; j < itempPlay; j++) {
                    QMediaContent media = pPlaylist->media(j); // Get the media item at the specified index
                    if(url == media.request().url())
                    {// Get the URL of the media item
                        pPlaylist->setCurrentIndex(j);
                        break;
                    }
                }
                //调用进程处理，暂停视频按钮
                this->process->write("quit\n");
                // Play the selected video
                play(url.toString(),ui->widget_55->winId());
                //                pPlaye->stop(); // Stop any ongoing playback
                //                pPlaye->setMedia(url);
                // pViedo->resize(ui->widget_55->size());//设置成标签大小
                //pViedo->setGeometry(ui->video->geometry()); // Set the video widget geometry
                ui->listWidget->setCurrentItem(item);
                //   pPlaye->play();
                qDebug() <<"播放"<< url;
                break;
            }
            else if (nextVideoIndex != -1) {
                pPlaylist->setCurrentIndex(0);

                QMediaContent media = pPlaylist->media(0); // Get the media item at the specified index
                QUrl url = media.request().url(); // Get the URL of the media item
                play(url.toString(),ui->widget_55->winId());
                //                pPlaye->stop(); // Stop any ongoing playback
                //                pPlaye->setMedia(url);
                //pViedo->resize(ui->widget_55->size());//设置成标签大小
                // Get the corresponding list item
                QListWidgetItem* nextVideoItem = ui->listWidget->item(nextVideoIndex);

                // Set the selected item in the list widget
                ui->listWidget->setCurrentItem(nextVideoItem);//设置当前列表指向
                qDebug() <<"播放1"<< url;
                // Play the video
                // pPlaye->play();
            }
        }


    }
    else if (nextVideoIndex != -1) {
        pPlaylist->setCurrentIndex(0);

        QMediaContent media = pPlaylist->media(0); // Get the media item at the specified index
        QUrl url = media.request().url(); // Get the URL of the media item
        //        pPlaye->stop(); // Stop any ongoing playback
        //        pPlaye->setMedia(url);
        //pViedo->resize(ui->video->size());//设置成标签大小
        // Get the corresponding list item
        QListWidgetItem* nextVideoItem = ui->listWidget->item(nextVideoIndex);

        // Set the selected item in the list widget
        ui->listWidget->setCurrentItem(nextVideoItem);//设置当前列表指向
        //调用进程处理，暂停视频按钮
        this->process->write("quit\n");
        // Play the selected video
        play(url.toString(),ui->widget_55->winId());
        //        // Play the video
        //        pPlaye->play();
    }
}
//暂停
void MainWindow::on_pushButton_4_clicked()
{
    //调用进程处理，暂停视频按钮
    this->process->write("quit\n");
    //    //    this->process->write("stop\n");
    //    ui->on_videohorizontalSlider_sliderMoved->setSliderPosition(0);//暂停之后播放进度条默认值为0

    //    ui->label_3_totletimeLable->clear();//播放进度条为0数值变化label

    //    ui->label_currenttimelable->clear();//当前进度显示的时间

    //    ui->label_precentlable->clear();//当前进度的百分比系数
    //    //设置视频的按钮图标样式
    //    //QPixmap pixmap;
    //    //pixmap.load("/home/llw/Desktop/Qt-mplayer-master/images/voice.png");
    //    //QPixmap pixmap3;
    //    //pixmap3.load("/home/llw/Desktop/Qt-mplayer-master/images/start.png");
    //    // ui->startButton->setFixedSize(pixmap.width(),pixmap.height());
    //    //ui->startButton->setIcon(pixmap3);
    //    //ui->startButton->setIconSize(QSize(pixmap.width(),pixmap.height()));
    //    ui->pushButton_zantingorstart->setToolTip("开始播放视频");
    //    ui->pushButton_zantingorstart->show();//显示暂停时候视频播放的内容
    // pPlaye->pause();
}
//停止
void MainWindow::on_pushButton_5_clicked()
{
    //进程控制发送暂停
    this->process->write("pause 1\n");
    //pPlaye->stop();
}
////跟随窗体大小变化
//void MainWindow::paintEvent(QPaintEvent *e)
//{
//    if(isOpen)
//    {
//       // pViedo->resize(ui->widget_55->size());//设置成标签大小
//        //pViedo->resize(ui->video_Police->size());//设置成标签大小
//    }
//    if(isOpen1)
//    {
//        //pViedo->resize(ui->audio->size());//设置成标签大小
//    }
//}

bool MainWindow::eventFilter(QObject *watched, QEvent *event)
{
    Q_UNUSED(watched);
    //  qDebug()<< this->windowState();	//打印窗口状态
    if (event->type() == QEvent::WindowStateChange)
    {

        if (m_eCurrentWindowState == Qt::WindowMinimized && m_eOldWindowState == Qt::WindowFullScreen)
        {
            this->showFullScreen();
            m_eOldWindowState = Qt::WindowMinimized;
            m_eCurrentWindowState = Qt::WindowFullScreen;
        }
    }
    return QObject::eventFilter(watched, event);

}
//上一个
void MainWindow::on_pushButton_7_clicked()
{
    int currentIndex = pPlaylist->currentIndex();
    int previousIndex = currentIndex - 1;
    // 查找上面没有回到最后
    if (previousIndex < 0) {
        previousIndex = pPlaylist->mediaCount() - 1;
    }

    QMediaContent media = pPlaylist->media(previousIndex); // Get the media item at the specified index
    QUrl url = media.request().url(); // Get the URL of the media item
    //    pPlaye->stop();
    //    pPlaye->setMedia(url);
    // pViedo->resize(ui->widget_55->size());//设置成标签大小
    pPlaylist->setCurrentIndex(previousIndex);
    //调用进程处理，暂停视频按钮
    this->process->write("quit\n");
    // Play the selected video
    play(url.toString(),ui->widget_55->winId());
    //    // Play the video
    //    pPlaye->play();
    // 在控件 ui->listWidget 中查找并选中值为指定值的行
    QString valueToFind =url.toString();
    Qt::MatchFlags flags = Qt::MatchExactly; // 精确匹配标志
    QList<QListWidgetItem *> foundItems = ui->listWidget->findItems(valueToFind.replace(0, 1, valueToFind.at(0).toUpper()), flags);
    // 遍历找到的项
    for (QListWidgetItem* item : foundItems) {
        // 处理找到的项
        // 例如，访问项的文本或其他属性
        QString itemText = item->text();
        qDebug() << itemText;
        ui->listWidget->setCurrentItem(item);
    }

}
//下一个
void MainWindow::on_pushButton_8_clicked()
{

    int currentIndex = pPlaylist->currentIndex();
    int nextIndex = currentIndex + 1;
    // Find the next valid video index
    int itemCount = pPlaylist->mediaCount();
    if (nextIndex >= itemCount) {
        nextIndex = 0;
    }
    QMediaContent media = pPlaylist->media(nextIndex); // Get the media item at the specified index
    QUrl url = media.request().url(); // Get the URL of the media item
    //    pPlaye->stop();
    //    pPlaye->setMedia(url);
    //pViedo->resize(ui->widget_55->size());//设置成标签大小
    pPlaylist->setCurrentIndex(nextIndex);
    //调用进程处理，暂停视频按钮
    this->process->write("quit\n");
    // Play the selected video
    play(url.toString(),ui->widget_55->winId());
    //    // Play the video
    //    pPlaye->play();
    // 在控件 ui->listWidget 中查找并选中值为指定值的行
    QString valueToFind =url.toString();
    Qt::MatchFlags flags = Qt::MatchExactly; // 精确匹配标志
    QList<QListWidgetItem *> foundItems = ui->listWidget->findItems(valueToFind.replace(0, 1, valueToFind.at(0).toUpper()), flags);
    // 遍历找到的项
    for (QListWidgetItem* item : foundItems) {
        // 处理找到的项
        // 例如，访问项的文本或其他属性
        QString itemText = item->text();
        qDebug() << itemText;
        ui->listWidget->setCurrentItem(item);
    }
}
////音量
//void MainWindow::on_horizontalSlider_2_valueChanged(int value)
//{
//    pPlaye->setVolume(value);
//    // Update the volumelabel to display the volume percentage
//    QString volumeText = QString::number(value) + "%";
//    ui->volumelabel->setText(volumeText);
//}
//进度
//void MainWindow::on_horizontalSlider_valueChanged(int value)
//{

//    QString scheduleText = currentTimeString + " / " + totalTime;
//    ui->schedulelabel->setText(scheduleText);
//    pPlaye->setPosition((qint64)value);
//    // Get the current playback time in seconds
//    qint64 currentPosition = pPlaye->position() / 1000;
//    // Get the total video duration in seconds
//    qint64 totalDuration = pPlaye->duration() / 1000;

//    // Format the current playback time and total video time
//    QString currentTimeString = QTime(0, 0).addSecs(currentPosition).toString("hh:mm:ss");
//    QString totalTimeString = QTime(0, 0).addSecs(totalDuration).toString("hh:mm:ss");

//    // Update the schedulelabel to display the current playback time and total video time
//    QString scheduleText = currentTimeString + " / " + totalTimeString;
//    ui->schedulelabel->setText(scheduleText);
//}
//播放结束循环播放
void MainWindow::getNextVideoAndPlay()
{

    QList<QListWidgetItem*> selectedItems = ui->listWidget->selectedItems();
    if (!selectedItems.isEmpty()) {
        foreach (QListWidgetItem* item, selectedItems) {
            QString path = item->text(); // Assuming the path is stored as text in each item
            //选中的音频播放加入到队列中
            QUrl url(path);
            QStringList videoFormats = {"mp4", "avi", "mkv", "mov"}; // Add more video formats if needed
            QString fileExtension = url.fileName().section('.', -1);
            if (videoFormats.contains(fileExtension, Qt::CaseInsensitive)) {
                // Play the selected video
                //                pPlaye->stop(); // Stop any ongoing playback
                //                pPlaye->setMedia(url);
                // pViedo->resize(ui->widget_55->size());//设置成标签大小
                //pViedo->setGeometry(ui->video->geometry()); // Set the video widget geometry
                ui->listWidget->setCurrentItem(item);
                //调用进程处理，暂停视频按钮
                this->process->write("quit\n");
                // Play the selected video
                play(url.toString(),ui->widget_55->winId());
                // pPlaye->play();
                break;
            }
            else
            {
                //如果不是视频，自动获取下一个是视频格式的进行播放
                //int nextIndex = -1;
                int currentIndex = ui->listWidget->row(item);
                int itemCount = ui->listWidget->count();
                for (int i = currentIndex + 1; i < itemCount; i++) {
                    QListWidgetItem* nextItem = ui->listWidget->item(i);
                    QString nextPath = nextItem->text();
                    QUrl nextUrl(nextPath);
                    QString nextFileExtension = nextUrl.fileName().section('.', -1);

                    if (videoFormats.contains(nextFileExtension, Qt::CaseInsensitive)) {
                        // Play the selected video
                        //                        pPlaye->stop(); // Stop any ongoing playback
                        //                        pPlaye->setMedia(url);
                        // pViedo->resize(ui->widget_55->size());//设置成标签大小
                        // pViedo->setGeometry(ui->video->geometry()); // Set the video widget geometry
                        ui->listWidget->setCurrentItem(nextItem);
                        //调用进程处理，暂停视频按钮
                        this->process->write("quit\n");
                        // Play the selected video
                        play(url.toString(),ui->widget_55->winId());
                        //                        pPlaye->play();
                        //nextIndex = i; // Update the next index for future iterations
                        break;
                    }

                }
            }
        }
    }
    else
    {


    }

}
//结束获取
void MainWindow::onMediaStatusChanged(QMediaPlayer::MediaStatus status)
{
    if (status == QMediaPlayer::EndOfMedia) {
        // 当前视频播放完毕，继续进行播放
        getNextVideoAndPlay();
    }
}

void MainWindow::displayPhoto(const QString& filePath)
{
    //    // 创建 QPixmap 对象并加载照片
    //    QPixmap photo(filePath);

    //    // 调整照片尺寸以适应 label_30 控件
    //    QPixmap scaledPhoto = photo.scaled(ui->picture->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);

    //    // 在 label_30 控件中显示照片
    //    ui->picture->setPixmap(scaledPhoto);
    //    ui->picture->setScaledContents(true); // 自动缩放图片以适应控件大小
    viewer->setImage(filePath);
    viewer->scale(1,1);
}
//打开日记
void MainWindow::displayDiary(const QString& filePath)
{
    // 打开日记文件
    QFile file(filePath);
    if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
        // 处理文件打开失败的情况
        return;
    }

    // 读取日记文件内容
    QTextStream in(&file);
    QString diaryContent = in.readAll();

    // 在 label_30 控件中显示日记内容
    ui->log->setText(diaryContent);

    // 关闭文件
    file.close();
}
int  MainWindow::calculateNumbers(int X, int Y) {

    QJsonObject jsonObject;
    jsonObject["Row"] = X;
    jsonObject["Column"] = Y;
    Send(ACQUISITION_STATION,INTERFACE_SELECTED_PORT_C,jsonObject);

    for(int i=1;i<=SYSTEMROW*SYSTEMLIST;++i)
    {
        IsInitalize[i]=false;//重新已经初始化
        SetLabel(i,"通用","","禁用",0);

    }
    if(AppointFirstNum>0)
    {
        SetLabel(AppointFirstNum,"优先","","禁用",0);
    }
    for (int row = 1; row <= X; row++) {
        for (int col = 1; col <= Y; col++) {
            int number = (row - 1) * 5 + col;  // 计算当前格子的数字
            IsInitalize[number]=true;

            SetLabel(number,"","","未初始化",1);
        }
    }
    SetLabel(1,"","","正在初始化",1);
    return 1;
}

void MainWindow::on_row_activated(int index)
{
    Newrow=index+1;
    // row=index+1;
    //    for(int i=1;i<=SYSTEMROW*SYSTEMLIST;++i)
    //    {
    //        IsALLlist[i]=false;
    //        TemporaryPath[i]="";
    //    }
    calculateNumbers(Newrow,Newcolumn);
    //ResetTing();
}

void MainWindow::on_list_activated(int index)
{
    Newcolumn=index+1;
    // column=index+1;
    //    for(int i=1;i<=SYSTEMROW*SYSTEMLIST;++i)
    //    {
    //        IsALLlist[i]=false;
    //        TemporaryPath[i]="";
    //    }
    calculateNumbers(Newrow,Newcolumn);
    //ResetTing();
}

void MainWindow::on_configure_button_clicked()
{
    // 获取应用程序的当前目录
    QString currentDir = QCoreApplication::applicationDirPath();
    // 设置初始路径
    QString initialPath = "/config_route.ini";
    // 拼接完整的文件路径
    QString filePath = currentDir + "/" + initialPath;

    // 使用QDesktopServices打开文件
    QUrl fileUrl = QUrl::fromLocalFile(filePath);
    QDesktopServices::openUrl(fileUrl);
}

//指定优先，指定重置选择
void MainWindow::on_comboBox_num_activated(int index)
{
    //    if(IsInitalize[index])
    //    {
    //    if(IsAppointFirst&&IsResetPath==0)//是否指定优先
    //    {
    SetLabel(AppointFirst,"通用","","",-1);
    if(AppointFirstNum>0)//上一个大于等于0
    {

        SetLabel(AppointFirstNum,"通用","","",-1);
    }

    if(index==0)
    {
        AppointFirst=1;
    }
    else
    {
        AppointFirst=index;
        qDebug()<<"on_comboBox_num_activated.AppointFirstNum="<<AppointFirst;
    }
    IsAppointFirst=true;
    SetLabel(AppointFirst,"优先","","",-1);


}

void MainWindow::on_pushButton_6_clicked()
{
    QJsonObject jsonObject;
    jsonObject["Message"] = EXIT;
    Send(ACQUISITION_STATION,INTERFACE_MAPPING_EXIT_C,jsonObject);

    //    QJsonObject jsonObject;
    //    jsonObject["Message"] = EXIT;
    //    Send(ACQUISITION_STATION,INTERFACE_MAPPING_EXIT_C,jsonObject);

    //    Refresh();
    //    IsResetPath=false;
    //    if(IsPriorlize[AppointFirstNum])
    //    {
    //        ui->comboBox_num->setVisible(true);
    //        ui->radioButton_resetradio->setChecked(false);
    //        ui->radioButton_appoint->setChecked(true);
    //        ui->radioButton_without->setChecked(false);

    //    }
    //    else
    //    {
    //        ui->comboBox_num->setVisible(false);
    //        ui->radioButton_resetradio->setChecked(false);
    //        ui->radioButton_appoint->setChecked(false);
    //        ui->radioButton_without->setChecked(true);
    //    }
    //    ui->stackedWidget->setCurrentWidget(ui->page);//切换页面
}

void MainWindow::ResetTing()//重置
{
    for(int j=1;j<=SYSTEMROW*SYSTEMLIST;++j)
    {
        if(IsInitalize[j]&&!IsALLlist[j])//此串口还没存在，并且获取的最新位置信息不为空
        {
            SetLabel(j,"","","正在初始化",1);
            NewSerialportNum =j;
            break;
        }

    }

}

//void MainWindow::Jump(int index,bool isSuccess)//跳转到主页面
//{
//    //ui->stackedWidget->setCurrentWidget(ui->page);//切换页面

//    //    if(isSuccess)
//    //    {
//    //        //SetLabel(myVec[index-1].serialportnum+100,"空闲","","",true);
//    //        SetLabel(index+100,QString("%1.转盘成功").arg(index),true);
//    //    }
//    //    else
//    //    {
//    //        SetLabel(index+100,QString("%1.转盘失败").arg(index),true);

//    //    }
//    return;

//}

//登录
bool MainWindow::OpenLoginDialog(QString& UserID,QString& Password,QString Serialnum,int sign,int index) {
    on_photograph_clicked();
    switch (sign) {
    case 1:
    {
        dialog.Open();
        IsClosingLogin=false;
        if (dialog.exec() == QDialog::Accepted) {
            // 登录成功，执行相应操作
            //    //读取配置文件

            UserID=dialog.usernameLineEdit->text();
            Password=dialog.passwordLineEdit->text();
            config.WriteInfo(QString("LoginDialog%1,%2").arg(UserID).arg(Password));
            if(UserID==""||Password=="")
            {
                QMessageBox::critical(nullptr, tr("错误"), tr("账号或密码不能为空"));
            }
            if(index==1)
            {


                QJsonObject jsonObject;
                jsonObject["UserID"] = UserID;
                jsonObject["Password"] = Password;
                Send(ACQUISITION_STATION,INTERFACE_BACKGROUND_LOGIN_C,jsonObject);
            }
            else if(index==2)
            {

                QJsonObject jsonObject;
                jsonObject["UserID"] = UserID;
                jsonObject["Password"] = Password;
                NewUserID=UserID;

                Send(ACQUISITION_STATION,INTERFACE_QUERY_C,jsonObject);
            }
            //             else if(index==3)
            //             {

            //                 QJsonObject jsonObject;
            //                 jsonObject["UserID"] = UserID;
            //                 jsonObject["Password"] = Password;

            //                 Send(ACQUISITION_STATION,INTERFACE_SYSTEMRESTART_C,jsonObject);
            //             }
            //             else if(index==4)
            //             {

            //                 QJsonObject jsonObject;
            //                 jsonObject["UserID"] = UserID;
            //                 jsonObject["Password"] = Password;

            //                 Send(ACQUISITION_STATION,INTERFACE_EXIT_C,jsonObject);
            //             }
            //             else if(index==5)
            //             {

            //                 QJsonObject jsonObject;
            //                 jsonObject["UserID"] = UserID;
            //                 jsonObject["Password"] = Password;
            //                 config.WriteInfo(QString("FINGERPRINT_CONFIG_C%1,%2").arg(UserID).arg(UserID));
            //                 Send(ACQUISITION_STATION,FINGERPRINT_CONFIG_C,jsonObject);
            //             }
            //             else if(index==6)
            //             {
            //                 QJsonObject jsonObject;
            //                 jsonObject["UserID"] = UserID;
            //                 jsonObject["Password"] = Password;
            //                 Send(ACQUISITION_STATION,DOOR_OPEN_C,jsonObject);
            //                 //break;
            //             }
            IsClosingLogin=true;
            dialog.Close();
            //dialog.Delete();
        } else {
            // 用户取消登录
            qDebug() << "Login canceled.";
            IsClosingLogin=true;
            dialog.Close();
            //dialog.Delete();
            break;
        }
        break;

    }

    case 5:
    {
        dialog.Open();
        IsClosingLogin=false;
        if (dialog.exec() == QDialog::Accepted) {
            // 登录成功，执行相应操作
            //    //读取配置文件
            QString password="";
            QString username="";
            //            config.ReadInfo("config.ini","TheLocalKey",username);
            //            config.ReadInfo("config.ini","TheLocalKeyPDW",password);
            UserID=dialog.usernameLineEdit->text();
            Password=dialog.passwordLineEdit->text();
            QJsonObject jsonObject;
            jsonObject["UserID"] = UserID;
            jsonObject["Password"] = Password;
            Send(ACQUISITION_STATION,INTERFACE_MAPPING_C,jsonObject);
            IsClosingLogin=true;
            dialog.Close();
            //dialog.Delete();
            //            QString ResultMess = "";
            //            int UserPrevilege = 0;
            //            qDebug() << dialog.passwordLineEdit->text()<<password<<dialog.usernameLineEdit->text()<<username;
            //            if(dialog.passwordLineEdit->text()==password&&dialog.usernameLineEdit->text()==username)
            //            {
            //                qDebug() << "Login successful!";
            //                return true;
            //            }else if(http.chkUser(UserID, Password, 0, UserPrevilege, ResultMess))
            //            {

            //                qDebug() << "Login successful!";
            //                return true;
            //            }
            //            else
            //            {
            //                QMessageBox::critical(nullptr, "错误", "账号密码错误.");
            //                break;
            //            }
        } else {
            // 用户取消登录
            qDebug() << "Login canceled.";
            IsClosingLogin=true;
            dialog.Close();
            //dialog.Delete();
            break;
        }
        break;
    }

    case 6:
    {
        SerialPort=index-100;
        if(IsWarnInstance&&Isbinding[index-100])
        {
            QJsonObject jsonObject;
            ui->label_userid->setText(userNo[index-100]);
            Send(ACQUISITION_STATION,POLICE_MODE_C,jsonObject);
        }
        else
        {
            SecondDialog.Open();
            SecondDialog.serialnumLineEdit->setText(Serialnum);
            if (SecondDialog.exec() == QDialog::Accepted) {
                // 登录成功，执行相应操作
                //    //读取配置文件

                UserID=SecondDialog.usernameLineEdit->text();
                Password=SecondDialog.passwordLineEdit->text();
                qDebug() << "Serialnum"<<Serialnum;

                Serialnum=SecondDialog.serialnumLineEdit->text();
                if(UserID==""||Password=="")
                {
                    QMessageBox::critical(nullptr, tr("错误"), tr("账号或密码或序列号不能为空"));
                    break;
                }
                if(Serialnum==""||Serialnum.length()!=7)
                {
                    QMessageBox::critical(nullptr, tr("错误"), tr("序列号不为7位"));
                    qDebug() << "请填写序列号";
                    break;
                }
                userNo[index-100]=UserID;
                userName[index-100]=UserID;
                ui->label_userid->setText(userNo[index-100]);
                QJsonObject jsonObject;
                jsonObject["UserID"] = UserID;
                jsonObject["Password"] = Password;
                jsonObject["IdentNumber"] = Serialnum;
                jsonObject["SerialportNum"] = index;
                Send(ACQUISITION_STATION,UPLOAD_LOGIN_C,jsonObject);
                //            if(http.GetUserByPoliceNum(UserID, Password)==1)
                //            {

                //                qDebug() << "Login successful!";
                //                return true;
                //            }
                //            else
                //            {
                //                QMessageBox::critical(nullptr, "错误", "账号密码错误.");
                //                break;
                //            }
                ////dialog.Delete2();
                SecondDialog.Close();
            } else {
                //dialog.Delete2();
                SecondDialog.Close();
                // 用户取消登录
                qDebug() << "Login canceled.";
                break;
            }
        }
        break;
    }

    default:
        qDebug() << "Login canceled.";
        break;
    }
    return false;

}
//保存设置
void MainWindow::on_save_configButton_clicked()
{
    //AppointFirstNum=AppointFirst;
    QJsonObject jsonObject;
    jsonObject["Row"] = Newrow;
    jsonObject["Column"] = Newcolumn;
    jsonObject["AppointFirst"] = AppointFirst;
    Send(ACQUISITION_STATION,INTERFACE_MAPPING_SAVE_C,jsonObject);

    //    IsResetPath=false;
    //    config.UpdateRouteValueInfo("config_record.ini","List",QString("%1").arg(column));
    //    config.UpdateRouteValueInfo("config_record.ini","Row",QString("%1").arg(row));

    //    for(int i=1;i<=SYSTEMROW*SYSTEMLIST;++i)
    //    {
    //        myVec[i-1].route = TemporaryPath[i];
    //        //myVecEnd[i-1].route = TemporaryPath[i];
    //        if(config.UpdateRouteValueInfo("config_route.ini",QString("Initalize_%1").arg(i),TemporaryPath[i]))//将串口写入
    //        {
    //            TemporaryPath[i]="";
    //        }
    //    }

    // 创建信息框并显示


}


////获取新的盘符
//void MainWindow::CheckDriveChanges()
//{

//    QDir dir("/");
//    QFileInfoList drives = dir.drives();
//    QSet<QString> newDrives;

//    for (const QFileInfo& drive : drives)
//    {
//        newDrives.insert(drive.absoluteFilePath());
//        if (!currentDrives.contains(drive.absoluteFilePath()))
//        {
//            qDebug() << "New drive detected:" << drive.absoluteFilePath();
//        }
//    }

//    for (const QFileInfo& drive : currentDrives)
//    {
//        if (!newDrives.contains(drive.absoluteFilePath()))
//        {
//            qDebug() << "Drive removed:" << drive.absoluteFilePath();
//        }
//    }

//    currentDrives = newDrives;
//}

//void MainWindow::handleThreadNotice(int indentID,QString title)
//{

//    qDebug() << "handleThreadNotice";
//    if(indentID==THREADNOTICE)
//    {
//        BackError=0;
//        emit GlobalSignals::instance().SetLabel(-5,"","","",-1);
//        return;
//    }
//    else if(indentID==-THREADNOTICE)
//    {
//        BackError++;
//        if(BackError>=10)
//        {
//            BackError=0;
//            //启动进程
//            runstart();
//        }
//        return;
//    }
//    return;

//}
//void MainWindow::handleThreadUpload(int indentID,int SerialportNum)
//{
//    qDebug() << "handleThreadUpload";
//    if(indentID==TUPLOAD||indentID==TUPLOADTWO)
//    {
//        emit GlobalSignals::instance().SetLabel(SerialportNum+100,"",QString("盘符路径:%1\n序列号:%2").arg(IsUdisk[SerialportNum]).arg(IdentNumber[SerialportNum]),"上传完成",-1);

//    }
//    else if(indentID==-TUPLOAD||indentID==-TUPLOADTWO)
//    {
//        emit GlobalSignals::instance().SetLabel(SerialportNum+100,"",QString("盘符路径:%1\n序列号:%2").arg(IsUdisk[SerialportNum]).arg(IdentNumber[SerialportNum]),"上传失败",-1);
//    }
//    return;

//}

inline void MainWindow::Send(int ParentID,int SubID,QJsonObject Data)
{
    threadinfo.Indet=0;
    threadinfo.ParentID=ParentID;
    threadinfo.SubID=SubID;
    threadinfo.Data=Data;
    if (ClientSocket->state() == QAbstractSocket::ConnectedState) {
        // msg=ui->lineEdit_14->text();
        QJsonObject jsonObject;
        jsonObject["ParentID"] = ParentID;
        jsonObject["SubID"] = SubID;
        jsonObject["Data"] = Data;
        // 将JSON对象转换为JSON文档
        QJsonDocument jsonDocument(jsonObject);

        // 将JSON文档转换为格式化的JSON字符串
        QByteArray jsonByteArray = jsonDocument.toJson(QJsonDocument::Indented);
        jsonByteArray+="end\n";
        qDebug() << "QByteArray:" << jsonByteArray;
        ClientSocket->write(jsonByteArray);
    } else {

        qDebug() << "未建立连接，请先建立连接。";
        //on_pushButton_12_clicked();
        // 执行连接建立的逻辑，或者给出错误提示

    }
    //threadHeartbeat->PushTask(threadinfo,true);
}
void MainWindow::on_label_icon_Clicked()
{
    if(!IsLock)
    {
        // 将主窗口最小化到系统托盘
        this->setWindowState(Qt::WindowMinimized);
        m_eCurrentWindowState = Qt::WindowMinimized; // 修改当前状态为最小化
        m_eOldWindowState = Qt::WindowFullScreen;	 // 修改之前状态为全屏
    }
}
void MainWindow::on_label_58_Clicked()
{
    QString UserID="";
    QString Password="";
    LoginDialog loginDialog;
    if (loginDialog.exec() == QDialog::Accepted) {
        // 登录成功，执行相应操作
        //    //读取配置文件

        UserID=loginDialog.usernameLineEdit->text();
        Password=loginDialog.passwordLineEdit->text();
        if(UserID==""||Password=="")
        {
            QMessageBox::critical(nullptr, "错误", "账号或密码不能为空");
        }
        else
        {
            IsLock=true;
            QJsonObject jsonObject;
            jsonObject["UserID"] = UserID;
            jsonObject["Password"] = Password;
            // Send(ACQUISITION_STATION,INTERFACE_MAPPING_C,jsonObject);
        }

    }
    else
    {

        UserID=loginDialog.usernameLineEdit->text();
        Password=loginDialog.passwordLineEdit->text();
        if(UserID==""||Password=="")
        {
            QMessageBox::critical(nullptr, "错误", "账号或密码不能为空");
        }
        else
        {
            IsLock=false;
            QJsonObject jsonObject;
            jsonObject["UserID"] = UserID;
            jsonObject["Password"] = Password;
            // Send(ACQUISITION_STATION,INTERFACE_MAPPING_C,jsonObject);
        }
    }
}


void MainWindow::on_pushButton_clicked()
{
    QString UserID="",Password="";
    if(!OpenLoginDialog(UserID,Password,"",1,2))//登录
    {
        return;
    }
    //StayScreen=2;//停留界面
    //ui->stackedWidget->setCurrentWidget(ui->page_2);//切换页面

}


void MainWindow::on_pushButton_9_clicked()
{

    QString text;
    int itemCount = ui->listWidget->count();//获取数量
    int nextVideoIndex = -1;
    for (int i = 0; i < itemCount; i++) {
        QListWidgetItem* item = ui->listWidget->item(i);
        QString path = item->text(); // 获取路径文本
        if(encryptFile(path,"TCL123"))
        {
            text=QString("%1:加密完成！").arg(path);
            //ui->textBrowser_message->append(text);
            qDebug() <<path<<"加密完成！";
        }
        else
        {
            text=QString("%1:加密失败！").arg(path);
            // ui->textBrowser_message->append(text);
            qDebug() <<path<<"加密失败！";
        }
    }

    //    GetCPUOccupancy();
    //    GetMemoryOccupancy();
    //    GetdiskOccupancy();
    //    //GetTcpInfo();
    //    // GetSystemNetDownloadRate();
    //    //GetSystemNetUploadRate();
}



void MainWindow::on_Query_clicked()
{
    ui->Query->setEnabled(false);
    // 在按钮点击事件开始时，将鼠标指针设置为等待状态
    QGuiApplication::setOverrideCursor(Qt::PointingHandCursor);
    // Lambda 表达式
    QTimer::singleShot(3000, this, [=](){
        int i=0;
        //    for(int j=0;j<lastNum;j++)
        //    {
        //        delete item[j];
        //        delete item1[j];
        //    }

        config.filelist.clear();
        QDateTime StartTime= ui->dateTimeEdit->dateTime();
        QDateTime EndTime= ui->dateTimeEdit_2->dateTime();
        QString Datetime=StartTime.toString("yyyyMMddhhmmss");
        QString Datetime_2=EndTime.toString("yyyyMMddhhmmss");
        QString OfficerID= ui->lineEdit->text();
        QString ProductNumber= ui->lineEdit_2->text();

        //config.findLogFiles("D:/www/sdv/Red5");
        if(OfficerID=="")
        {
            QMessageBox::critical(nullptr, tr("错误"), tr("用户编号不能为空."));
            ui->Query->setEnabled(true);
            QGuiApplication::restoreOverrideCursor();
            return ;
        }
        if(NewUserStatus==1&&NewUserID==OfficerID)
        {

            config.findFilesByCreationDate(QString("%1").arg(config.UploadUrl), Datetime, Datetime_2,OfficerID,ProductNumber);
        }
        else
        {
            config.WriteInfo(QString("CX %1%2").arg(config.UploadUrl).arg(OfficerID));
            config.findFilesByCreationDate(QString("%1%2").arg(config.UploadUrl).arg(OfficerID), Datetime, Datetime_2,OfficerID,ProductNumber);
        }


        //遍历所有控件状态
        for (auto& deviceInfo : config.filelist) {
            int nCount=ui->tableWidget->rowCount();
            if(nCount<=i)
            {
                ui->tableWidget->insertRow(i);
            }
            item[i]= new QTableWidgetItem(QString("%1").arg(deviceInfo.lastModified));
            ui->tableWidget->setItem(i,0,item[i]);
            item1[i]= new QTableWidgetItem(QString("%1(%2)").arg(OfficerID).arg(deviceInfo.productNumber));
            ui->tableWidget->setItem(i,1,item1[i]);
            i++;
            if(i>9999)
            {
                QMessageBox::critical(nullptr, tr("提示"), tr("文件数量大于9999,请删除文件。"));
                ui->Query->setEnabled(true);
                QGuiApplication::restoreOverrideCursor();
                return ;
            }
        }
        lastNum=i;
        if(i==0)
        {
            QMessageBox::critical(nullptr, tr("提示"), tr("没有找到数据."));
            ui->Query->setEnabled(true);
            QGuiApplication::restoreOverrideCursor();
            return ;
        }
        ui->Query->setEnabled(true);
        QGuiApplication::restoreOverrideCursor();
    });
}



void MainWindow::on_tableWidget_cellClicked(int row, int column)
{
    pPlaylist->clear();
    ui->listWidget->clear();
    //    ui->listWidget_1->clear();
    //    ui->listWidget_2->clear();
    //    ui->listWidget_3->clear();
    config.video.clear();
    config.picture.clear();
    config.log.clear();
    config.audio.clear();

    QTableWidgetItem* item = ui->tableWidget->item(row, 0);  // 传入的行和列参数是从0开始计数的
    QTableWidgetItem* item1 = ui->tableWidget->item(row, 1);  // 传入的行和列参数是从0开始计数的
    if (item != nullptr) {

        QString key = item->text();
        QString value = item1->text();
        // 在这里使用获取到的值进行处理
        int openingBracketIndex = value.indexOf("(");
        int closingBracketIndex = value.indexOf(")");

        if (openingBracketIndex != -1 && closingBracketIndex != -1 && openingBracketIndex < closingBracketIndex) {
            QString insideBrackets = value.mid(openingBracketIndex + 1, closingBracketIndex - openingBracketIndex - 1);
            QString outsideBrackets = value.left(openingBracketIndex);

            qDebug() << "Inside brackets: " << insideBrackets;  // 输出括号内的内容
            qDebug() << "Outside brackets: " << outsideBrackets;  // 输出括号外的内容
            auto itdn = std::find_if(config.filelist.begin(), config.filelist.end(), [&](const FileOperation::FileInfo& finfo) {
                return finfo.lastModified==key&&finfo.productNumber==insideBrackets&&finfo.officerID==outsideBrackets;
            });
            if (itdn != config.filelist.end())
            {
                config.findFilesByCreationDate(itdn->sourceFilePath);
                switch (ui->tabWidget->currentIndex()) {
                case VIDEO:
                {
                    QString A="";
                    for (auto& deviceInfo : config.video) {
                        // ui->listWidget->addItem(deviceInfo);
                        qDebug() << deviceInfo;
                        QUrl url(deviceInfo);
                        QStringList videoFormats = {"mp4", "avi", "mkv", "mov"};
                        QString fileExtension = url.fileName().section('.', -1);
                        if (videoFormats.contains(fileExtension, Qt::CaseInsensitive)) { // 判断是否为视频
                            pPlaylist->addMedia(url); // 加入到播放列表中
                            A += deviceInfo;
                            A += '\n';

                        }
                    }
                    config.Write("DATA.ini",A);
                    break;
                }
                case PHOTO:
                {
                    for (auto& deviceInfo : config.picture) {
                        ui->listWidget->addItem(deviceInfo);
                        qDebug() << deviceInfo;
                    }
                    break;
                }
                case AUDIO:
                { QString A="";

                    for (auto& deviceInfo : config.audio) {
                        //  ui->listWidget->addItem(deviceInfo);

                        A += deviceInfo;
                        A += '\n';



                        qDebug() << deviceInfo;

                    }
                    config.Write("DATA.ini",A);
                    break;
                }
                case LOG:
                {
                    for (auto& deviceInfo : config.log) {
                        ui->listWidget->addItem(deviceInfo);
                        qDebug() << deviceInfo;
                    }
                    break;
                }
                default:
                {
                    qDebug() << "Login canceled.";
                    return;
                }
                }

            }

        }
    }
    else {
        // 指定的单元格不存在
    }
}
void MainWindow::on_listWidget_itemClicked(QListWidgetItem *item)
{
    switch (ui->tabWidget->currentIndex()) {
    case VIDEO:
    {
        on_pushButton_3_clicked();
        break;
    }
    case PHOTO:
    {
        displayPhoto(item->text());
        break;
    }
    case AUDIO:
    {
        on_pushButton_audio2_clicked();
        break;
    }
    case LOG:
    {
        displayDiary(item->text());
        break;
    }
    default:
    {
        qDebug() << "Login canceled.";
        return;
    }
    }
}

void MainWindow::on_pushButton_10_clicked()
{
    qDebug() << "on_pushButton_10_clicked";
    StayScreen=0;//停留界面
    // 假设你的QTableWidget叫做tableWidget
    int rowCount = ui->tableWidget->rowCount();

    // 清空除第一行以外的数据
    for (int i = rowCount; i >= 0; --i) {
        ui->tableWidget->removeRow(i);
    }

    ui->stackedWidget->setCurrentWidget(ui->page);//切换页面
    ui->widget_7->show();
}

void MainWindow:: handlePrint(QString text)
{
    //        if(InputNum>=100)
    //        {
    //            ui->textBrowser_message->clear();
    //            InputNum=0;
    //        }
    // ui->textBrowser_message->append(text);
    //  InputNum++;
    //config.WriteInfo(text);
    qInfo()<<text;
}


void MainWindow::on_pushButton_message_clicked()
{
    if(IsHide)
    {
        //ui->textBrowser_message->hide();
        IsHide=false;
    }
    else
    {
        //ui->textBrowser_message->show();
        IsHide=true;
    }
}

void MainWindow::on_tabWidget_currentChanged(int index)
{
    qDebug() << index;
    ui->listWidget->clear();
    switch (index) {
    case VIDEO:
    {
        for (auto& deviceInfo : config.video) {
            // ui->listWidget->addItem(deviceInfo);
            qDebug() << deviceInfo;
            QUrl url(deviceInfo);
            QStringList videoFormats = {"mp4", "avi", "mkv", "mov"};
            QString fileExtension = url.fileName().section('.', -1);
            if (videoFormats.contains(fileExtension, Qt::CaseInsensitive)) { // 判断是否为视频
                pPlaylist->addMedia(url); // 加入到播放列表中
            }
        }
        break;
    }
    case PHOTO:
    {
        for (auto& deviceInfo : config.picture) {
            ui->listWidget->addItem(deviceInfo);
            qDebug() << deviceInfo;
        }
        break;
    }
    case AUDIO:
    {

        for (auto& deviceInfo : config.audio) {
            // ui->listWidget->addItem(deviceInfo);
            qDebug() << deviceInfo;

        }
        break;
    }
    case LOG:
    {
        for (auto& deviceInfo : config.log) {
            ui->listWidget->addItem(deviceInfo);
            qDebug() << deviceInfo;
        }
        break;
    }
    default:
    {
        qDebug() << "Login canceled.";
        return;
    }
    }
}

void MainWindow::on_pushButton_Up_clicked()
{
    ui->widget_11->hide();

}

void MainWindow::on_pushButton_down_clicked()
{
    ui->widget_11->show();
}

void MainWindow::on_pushButton_right_clicked()
{
    ui->widget_17->hide();

}

void MainWindow::on_pushButton_left_clicked()
{
    ui->widget_17->show();
}

//void MainWindow::on_pushButton_resetradio_clicked()
//{
//    // config.DeleteSaveInfo("config_record.ini");//清空路径文件
//    config.DeleteSaveInfo("config_route.ini");//清空路径文件

//    for(int q=1;q<=(SYSTEMROW*SYSTEMLIST);q++)
//    {
//        SetLabel(q,"","","不可用",false);
//        config.UpdateRouteValueInfo("config_record.ini",QString("label_%1").arg(q),"");
//    }
//    int i=0;
//    //遍历所有控件状态
//    for (auto& deviceInfo : myVec) {
//        i++;
//        deviceInfo.pid="";
//        deviceInfo.vid="";
//        deviceInfo.route="";
//        deviceInfo.model="";
//        deviceInfo.manufacturer="";
//        deviceInfo.serialnumber="";
//        deviceInfo.serialportnum=i;
//        //deviceInfo.priority=false;
//        IsALLlist[i]=false;
//        //IsALL=false;
//    }

//    //清空配置文件
//    //重置所有内存
//    //初始化所有控件
//}

void MainWindow::on_radioButton_appoint_clicked(bool checked)
{
    ui->comboBox_num->setCurrentIndex(AppointFirstNum);

    AppointFirst=-1;
    if(checked)
    {
        qDebug()<<"指定优先口";
        ui->widget_3->show();
        ui->comboBox_num->setVisible(true);
        ui->radioButton_without->setChecked(false);
        //ui->radioButton_resetradio->setChecked(false);
        IsAppointFirst=true;

    }
    else
    {
        ui->comboBox_num->setVisible(false);
        ui->radioButton_without->setChecked(true);
        on_radioButton_without_clicked(true);

    }
    //calculateNumbers(Newrow,Newcolumn);//
    //ResetTing();
    //on_comboBox_num_activated(AppointFirstNum);
}

void MainWindow::on_radioButton_without_clicked(bool checked)
{
    if(checked)
    {
        SetLabel(AppointFirst,"通用","","",-1);
        AppointFirst=-1;
        qDebug()<<"不用优先口";
        ui->widget_3->show();
        ui->comboBox_num->setVisible(false);
        //ui->radioButton_resetradio->setChecked(false);
        ui->radioButton_appoint->setChecked(false);
        IsAppointFirst=false;

        //        // 移除布局中的对象并进行清理
        //        for(int i=1;i<=SYSTEMROW*SYSTEMLIST;++i)
        //        {
        //            if(layout[i]!=nullptr)
        //            {
        //                delete layout[i];
        //                layout[i]=nullptr;
        //            }
        //            if(imageLabel1[i]!=nullptr)
        //            {
        //                delete imageLabel1[i];
        //                imageLabel1[i]=nullptr;
        //            }
        //            if(imageLabel2[i]!=nullptr)
        //            {
        //                delete imageLabel2[i];
        //                imageLabel2[i]=nullptr;
        //            }
        //        }

    }
    else
    {
        ui->comboBox_num->setVisible(false);
        ui->radioButton_without->setChecked(true);
        on_radioButton_without_clicked(true);
    }
    //    calculateNumbers(row,column);//
    //    ResetTing();
}

//void MainWindow::on_radioButton_resetradio_clicked(bool checked)
//{
//    ui->comboBox_num->setCurrentIndex(-1);
//    if(checked)
//    {
//        IsResetPath=2;
//        ui->widget_3->hide();//隐藏
//        row=1;
//        column=1;
//        ui->row->setCurrentIndex(row-1);
//        ui->list->setCurrentIndex(column-1);
//        calculateNumbers(row,column);
//        qDebug()<<"指定重置";
//        ui->comboBox_num->setVisible(true);

//        ui->radioButton_appoint->setChecked(false);
//        ui->radioButton_without->setChecked(false);
//    }
//    else
//    {
//        ui->comboBox_num->setVisible(false);
//        ui->radioButton_without->setChecked(true);
//        on_radioButton_without_clicked(true);
//    }
//}
bool MainWindow::SetLabel(int Index,QString Text,QString TextInfo,QString Textprompt,int Display)
{


    // QApplication::processEvents();
    //    config.WriteInfo(QString("SetLabelIndex=%1").arg(Index));
    //    qDebug()<<"SetLabelIndex="<<Index<<Display;
    // QApplication::processEvents();
    switch (Index) {
    case 1:
    {
        if(Text!="")
            ui->label_1_1->setText(Text);
        if(TextInfo!="")
            ui->label_1_2->setText(TextInfo);
        if(Textprompt!="")
            ui->label_1_3->setText(Textprompt);

        if(Display==1)
        {
            ui->widget_21->show();
        }else if(Display==0)
        {
            ui->widget_21->hide();
        }
        break;
    }
    case 2:
    {
        if(Text!="")
            ui->label_2_1->setText(Text);
        if(TextInfo!="")
            ui->label_2_2->setText(TextInfo);
        if(Textprompt!="")
            ui->label_2_3->setText(Textprompt);

        if(Display==1)
        {
            ui->widget_22->show();
        }else if(Display==0)
        {
            ui->widget_22->hide();
        }
        break;
    }
    case 3:
    {
        if(Text!="")
            ui->label_3_1->setText(Text);
        if(TextInfo!="")
            ui->label_3_2->setText(TextInfo);
        if(Textprompt!="")
            ui->label_3_3->setText(Textprompt);

        if(Display==1)
        {
            ui->widget_23->show();
        }else if(Display==0)
        {
            ui->widget_23->hide();
        }
        break;
    }
    case 4:
    {
        if(Text!="")
            ui->label_4_1->setText(Text);
        if(TextInfo!="")
            ui->label_4_2->setText(TextInfo);
        if(Textprompt!="")
            ui->label_4_3->setText(Textprompt);

        if(Display==1)
        {
            ui->widget_24->show();
        }else if(Display==0)
        {
            ui->widget_24->hide();
        }
        break;
    }
    case 5:
    {
        if(Text!="")
            ui->label_5_1->setText(Text);
        if(TextInfo!="")
            ui->label_5_2->setText(TextInfo);
        if(Textprompt!="")
            ui->label_5_3->setText(Textprompt);

        if(Display==1)
        {
            ui->widget_25->show();
        }else if(Display==0)
        {
            ui->widget_25->hide();
        }
        break;
    }
    case 6:
    {
        if(Text!="")
            ui->label_6_1->setText(Text);
        if(TextInfo!="")
            ui->label_6_2->setText(TextInfo);
        if(Textprompt!="")
            ui->label_6_3->setText(Textprompt);

        if(Display==1)
        {
            ui->widget_26->show();
        }else if(Display==0)
        {
            ui->widget_26->hide();
        }
        break;
    }
    case 7:
    {
        if(Text!="")
            ui->label_7_1->setText(Text);
        if(TextInfo!="")
            ui->label_7_2->setText(TextInfo);
        if(Textprompt!="")
            ui->label_7_3->setText(Textprompt);

        if(Display==1)
        {
            ui->widget_27->show();
        }else if(Display==0)
        {
            ui->widget_27->hide();
        }
        break;
    }
    case 8:
    {
        if(Text!="")
            ui->label_8_1->setText(Text);
        if(TextInfo!="")
            ui->label_8_2->setText(TextInfo);
        if(Textprompt!="")
            ui->label_8_3->setText(Textprompt);

        if(Display==1)
        {
            ui->widget_28->show();
        }else if(Display==0)
        {
            ui->widget_28->hide();
        }
        break;
    }
    case 9:
    {
        if(Text!="")
            ui->label_9_1->setText(Text);
        if(TextInfo!="")
            ui->label_9_2->setText(TextInfo);
        if(Textprompt!="")
            ui->label_9_3->setText(Textprompt);

        if(Display==1)
        {
            ui->widget_29->show();
        }else if(Display==0)
        {
            ui->widget_29->hide();
        }
        break;
    }
    case 10:
    {
        if(Text!="")
            ui->label_10_1->setText(Text);
        if(TextInfo!="")
            ui->label_10_2->setText(TextInfo);
        if(Textprompt!="")
            ui->label_10_3->setText(Textprompt);

        if(Display==1)
        {
            ui->widget_30->show();
        }else if(Display==0)
        {
            ui->widget_30->hide();
        }
        break;
    }
    case 11:
    {
        if(Text!="")
            ui->label_11_1->setText(Text);
        if(TextInfo!="")
            ui->label_11_2->setText(TextInfo);
        if(Textprompt!="")
            ui->label_11_3->setText(Textprompt);

        if(Display==1)
        {
            ui->widget_31->show();
        }else if(Display==0)
        {
            ui->widget_31->hide();
        }
        break;
    }
    case 12:
    {
        if(Text!="")
            ui->label_12_1->setText(Text);
        if(TextInfo!="")
            ui->label_12_2->setText(TextInfo);
        if(Textprompt!="")
            ui->label_12_3->setText(Textprompt);

        if(Display==1)
        {
            ui->widget_32->show();
        }else if(Display==0)
        {
            ui->widget_32->hide();
        }
        break;
    }
    case 13:
    {
        if(Text!="")
            ui->label_13_1->setText(Text);
        if(TextInfo!="")
            ui->label_13_2->setText(TextInfo);
        if(Textprompt!="")
            ui->label_13_3->setText(Textprompt);

        if(Display==1)
        {
            ui->widget_33->show();
        }else if(Display==0)
        {
            ui->widget_33->hide();
        }
        break;
    }
    case 14:
    {
        if(Text!="")
            ui->label_14_1->setText(Text);
        if(TextInfo!="")
            ui->label_14_2->setText(TextInfo);
        if(Textprompt!="")
            ui->label_14_3->setText(Textprompt);

        if(Display==1)
        {
            ui->widget_34->show();
        }else if(Display==0)
        {
            ui->widget_34->hide();
        }
        break;
    }
    case 15:
    {
        if(Text!="")
            ui->label_15_1->setText(Text);
        if(TextInfo!="")
            ui->label_15_2->setText(TextInfo);
        if(Textprompt!="")
            ui->label_15_3->setText(Textprompt);

        if(Display==1)
        {
            ui->widget_35->show();
        }else if(Display==0)
        {
            ui->widget_35->hide();
        }
        break;
    }
    case 16:
    {
        if(Text!="")
            ui->label_16_1->setText(Text);
        if(TextInfo!="")
            ui->label_16_2->setText(TextInfo);
        if(Textprompt!="")
            ui->label_16_3->setText(Textprompt);

        if(Display==1)
        {
            ui->widget_36->show();
        }else if(Display==0)
        {
            ui->widget_36->hide();
        }
        break;
    }
    case 17:
    {
        if(Text!="")
            ui->label_17_1->setText(Text);
        if(TextInfo!="")
            ui->label_17_2->setText(TextInfo);
        if(Textprompt!="")
            ui->label_17_3->setText(Textprompt);

        if(Display==1)
        {
            ui->widget_37->show();
        }else if(Display==0)
        {
            ui->widget_37->hide();
        }
        break;
    }
    case 18:
    {
        if(Text!="")
            ui->label_18_1->setText(Text);
        if(TextInfo!="")
            ui->label_18_2->setText(TextInfo);
        if(Textprompt!="")
            ui->label_18_3->setText(Textprompt);

        if(Display==1)
        {
            ui->widget_38->show();
        }else if(Display==0)
        {
            ui->widget_38->hide();
        }
        break;
    }
    case 19:
    {
        if(Text!="")
            ui->label_19_1->setText(Text);
        if(TextInfo!="")
            ui->label_19_2->setText(TextInfo);
        if(Textprompt!="")
            ui->label_19_3->setText(Textprompt);

        if(Display==1)
        {
            ui->widget_39->show();
        }else if(Display==0)
        {
            ui->widget_39->hide();
        }
        break;
    }
    case 20:
    {
        if(Text!="")
            ui->label_20_1->setText(Text);
        if(TextInfo!="")
            ui->label_20_2->setText(TextInfo);
        if(Textprompt!="")
            ui->label_20_3->setText(Textprompt);

        if(Display==1)
        {
            ui->widget_40->show();
        }else if(Display==0)
        {
            ui->widget_40->hide();
        }
        break;
    }
    case 21:
    {
        if(Text!="")
            ui->label_21_1->setText(Text);
        if(TextInfo!="")
            ui->label_21_2->setText(TextInfo);
        if(Textprompt!="")
            ui->label_21_3->setText(Textprompt);

        if(Display==1)
        {
            ui->widget_41->show();
        }else if(Display==0)
        {
            ui->widget_41->hide();
        }
        break;
    }
    case 22:
    {
        if(Text!="")
            ui->label_22_1->setText(Text);
        if(TextInfo!="")
            ui->label_22_2->setText(TextInfo);
        if(Textprompt!="")
            ui->label_22_3->setText(Textprompt);

        if(Display==1)
        {
            ui->widget_42->show();
        }else if(Display==0)
        {
            ui->widget_42->hide();
        }
        break;
    }
    case 23:
    {
        if(Text!="")
            ui->label_23_1->setText(Text);
        if(TextInfo!="")
            ui->label_23_2->setText(TextInfo);
        if(Textprompt!="")
            ui->label_23_3->setText(Textprompt);

        if(Display==1)
        {
            ui->widget_43->show();
        }else if(Display==0)
        {
            ui->widget_43->hide();
        }
        break;
    }
    case 24:
    {
        if(Text!="")
            ui->label_24_1->setText(Text);
        if(TextInfo!="")
            ui->label_24_2->setText(TextInfo);
        if(Textprompt!="")
            ui->label_24_3->setText(Textprompt);

        if(Display==1)
        {
            ui->widget_44->show();
        }else if(Display==0)
        {
            ui->widget_44->hide();
        }
        break;
    }
    case 25:
    {
        if(Text!="")
            ui->label_25_1->setText(Text);
        if(TextInfo!="")
            ui->label_25_2->setText(TextInfo);
        if(Textprompt!="")
            ui->label_25_3->setText(Textprompt);

        if(Display==1)
        {
            ui->widget_45->show();
        }else if(Display==0)
        {
            ui->widget_45->hide();
        }
        break;
    }

    case 101:
    {
        if(Text!="")
            ui->label_101_1->setText(Text);
        if(TextInfo!="")
            ui->label_101_2->setText(TextInfo);
        if(Textprompt!="")
            ui->label_101_3->setText(Textprompt);

        if(Display==1)
        {
            ui->widget_121->show();
        }else if(Display==0)
        {
            ui->widget_121->hide();
        }
        break;
    }
    case 102:
    {
        if(Text!="")
            ui->label_102_1->setText(Text);
        if(TextInfo!="")
            ui->label_102_2->setText(TextInfo);
        if(Textprompt!="")
            ui->label_102_3->setText(Textprompt);

        if(Display==1)
        {
            ui->widget_122->show();
        }else if(Display==0)
        {
            ui->widget_122->hide();
        }
        break;
    }
    case 103:
    {
        if(Text!="")
            ui->label_103_1->setText(Text);
        if(TextInfo!="")
            ui->label_103_2->setText(TextInfo);
        if(Textprompt!="")
            ui->label_103_3->setText(Textprompt);

        if(Display==1)
        {
            ui->widget_123->show();
        }else if(Display==0)
        {
            ui->widget_123->hide();
        }
        break;
    }
    case 104:
    {
        if(Text!="")
            ui->label_104_1->setText(Text);
        if(TextInfo!="")
            ui->label_104_2->setText(TextInfo);
        if(Textprompt!="")
            ui->label_104_3->setText(Textprompt);

        if(Display==1)
        {
            ui->widget_124->show();
        }else if(Display==0)
        {
            ui->widget_124->hide();
        }
        break;
    }
    case 105:
    {
        if(Text!="")
            ui->label_105_1->setText(Text);
        if(TextInfo!="")
            ui->label_105_2->setText(TextInfo);
        if(Textprompt!="")
            ui->label_105_3->setText(Textprompt);

        if(Display==1)
        {
            ui->widget_125->show();
        }else if(Display==0)
        {
            ui->widget_125->hide();
        }
        break;
    }
    case 106:
    {
        if(Text!="")
            ui->label_106_1->setText(Text);
        if(TextInfo!="")
            ui->label_106_2->setText(TextInfo);
        if(Textprompt!="")
            ui->label_106_3->setText(Textprompt);

        if(Display==1)
        {
            ui->widget_126->show();
        }else if(Display==0)
        {
            ui->widget_126->hide();
        }
        break;
    }
    case 107:
    {
        if(Text!="")
            ui->label_107_1->setText(Text);
        if(TextInfo!="")
            ui->label_107_2->setText(TextInfo);
        if(Textprompt!="")
            ui->label_107_3->setText(Textprompt);

        if(Display==1)
        {
            ui->widget_127->show();
        }else if(Display==0)
        {
            ui->widget_127->hide();
        }
        break;
    }
    case 108:
    {
        if(Text!="")
            ui->label_108_1->setText(Text);
        if(TextInfo!="")
            ui->label_108_2->setText(TextInfo);
        if(Textprompt!="")
            ui->label_108_3->setText(Textprompt);

        if(Display==1)
        {
            ui->widget_128->show();
        }else if(Display==0)
        {
            ui->widget_128->hide();
        }
        break;
    }
    case 109:
    {
        if(Text!="")
            ui->label_109_1->setText(Text);
        if(TextInfo!="")
            ui->label_109_2->setText(TextInfo);
        if(Textprompt!="")
            ui->label_109_3->setText(Textprompt);

        if(Display==1)
        {
            ui->widget_129->show();
        }else if(Display==0)
        {
            ui->widget_129->hide();
        }
        break;
    }
    case 110:
    {
        if(Text!="")
            ui->label_110_1->setText(Text);
        if(TextInfo!="")
            ui->label_110_2->setText(TextInfo);
        if(Textprompt!="")
            ui->label_110_3->setText(Textprompt);

        if(Display==1)
        {
            ui->widget_130->show();
        }else if(Display==0)
        {
            ui->widget_130->hide();
        }
        break;
    }
    case 111:
    {
        if(Text!="")
            ui->label_111_1->setText(Text);
        if(TextInfo!="")
            ui->label_111_2->setText(TextInfo);
        if(Textprompt!="")
            ui->label_111_3->setText(Textprompt);

        if(Display==1)
        {
            ui->widget_131->show();
        }else if(Display==0)
        {
            ui->widget_131->hide();
        }
        break;

    }
    case 112:
    {
        if(Text!="")
            ui->label_112_1->setText(Text);
        if(TextInfo!="")
            ui->label_112_2->setText(TextInfo);
        if(Textprompt!="")
            ui->label_112_3->setText(Textprompt);

        if(Display==1)
        {
            ui->widget_132->show();
        }else if(Display==0)
        {
            ui->widget_132->hide();
        }
        break;
    }
    case 113:
    {
        if(Text!="")
            ui->label_113_1->setText(Text);
        if(TextInfo!="")
            ui->label_113_2->setText(TextInfo);
        if(Textprompt!="")
            ui->label_113_3->setText(Textprompt);

        if(Display==1)
        {
            ui->widget_133->show();
        }else if(Display==0)
        {
            ui->widget_133->hide();
        }
        break;
    }
    case 114:
    {
        if(Text!="")
            ui->label_114_1->setText(Text);
        if(TextInfo!="")
            ui->label_114_2->setText(TextInfo);
        if(Textprompt!="")
            ui->label_114_3->setText(Textprompt);

        if(Display==1)
        {
            ui->widget_134->show();
        }else if(Display==0)
        {
            ui->widget_134->hide();
        }
        break;

    }
    case 115:
    {
        if(Text!="")
            ui->label_115_1->setText(Text);
        if(TextInfo!="")
            ui->label_115_2->setText(TextInfo);
        if(Textprompt!="")
            ui->label_115_3->setText(Textprompt);

        if(Display==1)
        {
            ui->widget_135->show();
        }else if(Display==0)
        {
            ui->widget_135->hide();
        }
        break;

    }
    case 116:
    {
        if(Text!="")
            ui->label_116_1->setText(Text);
        if(TextInfo!="")
            ui->label_116_2->setText(TextInfo);
        if(Textprompt!="")
            ui->label_116_3->setText(Textprompt);

        if(Display==1)
        {
            ui->widget_136->show();
        }else if(Display==0)
        {
            ui->widget_136->hide();
        }
        break;

    }
    case 117:
    {
        if(Text!="")
            ui->label_117_1->setText(Text);
        if(TextInfo!="")
            ui->label_117_2->setText(TextInfo);
        if(Textprompt!="")
            ui->label_117_3->setText(Textprompt);

        if(Display==1)
        {
            ui->widget_137->show();
        }else if(Display==0)
        {
            ui->widget_137->hide();
        }
        break;

    }
    case 118:
    {
        if(Text!="")
            ui->label_118_1->setText(Text);
        if(TextInfo!="")
            ui->label_118_2->setText(TextInfo);
        if(Textprompt!="")
            ui->label_118_3->setText(Textprompt);

        if(Display==1)
        {
            ui->widget_138->show();
        }else if(Display==0)
        {
            ui->widget_138->hide();
        }
        break;

    }
    case 119:
    {
        if(Text!="")
            ui->label_119_1->setText(Text);
        if(TextInfo!="")
            ui->label_119_2->setText(TextInfo);
        if(Textprompt!="")
            ui->label_119_3->setText(Textprompt);

        if(Display==1)
        {
            ui->widget_139->show();
        }else if(Display==0)
        {
            ui->widget_139->hide();
        }
        break;

    }
    case 120:
    {
        if(Text!="")
            ui->label_120_1->setText(Text);
        if(TextInfo!="")
            ui->label_120_2->setText(TextInfo);
        if(Textprompt!="")
            ui->label_120_3->setText(Textprompt);

        if(Display==1)
        {
            ui->widget_140->show();
        }else if(Display==0)
        {
            ui->widget_140->hide();
        }
        break;

    }
    case 121:
    {
        if(Text!="")
            ui->label_121_1->setText(Text);
        if(TextInfo!="")
            ui->label_121_2->setText(TextInfo);
        if(Textprompt!="")
            ui->label_121_3->setText(Textprompt);

        if(Display==1)
        {
            ui->widget_141->show();
        }else if(Display==0)
        {
            ui->widget_141->hide();
        }
        break;


    }
    case 122:
    {
        if(Text!="")
            ui->label_122_1->setText(Text);
        if(TextInfo!="")
            ui->label_122_2->setText(TextInfo);
        if(Textprompt!="")
            ui->label_122_3->setText(Textprompt);

        if(Display==1)
        {
            ui->widget_142->show();
        }else if(Display==0)
        {
            ui->widget_142->hide();
        }
        break;

    }
    case 123:
    {
        if(Text!="")
            ui->label_123_1->setText(Text);
        if(TextInfo!="")
            ui->label_123_2->setText(TextInfo);
        if(Textprompt!="")
            ui->label_123_3->setText(Textprompt);

        if(Display==1)
        {
            ui->widget_143->show();
        }else if(Display==0)
        {
            ui->widget_143->hide();
        }
        break;
    }
    case 124:
    {
        if(Text!="")
            ui->label_124_1->setText(Text);
        if(TextInfo!="")
            ui->label_124_2->setText(TextInfo);
        if(Textprompt!="")
            ui->label_124_3->setText(Textprompt);

        if(Display==1)
        {
            ui->widget_144->show();
        }else if(Display==0)
        {
            ui->widget_144->hide();
        }
        break;
    }
    case 125:
    {
        if(Text!="")
            ui->label_125_1->setText(Text);
        if(TextInfo!="")
            ui->label_125_2->setText(TextInfo);
        if(Textprompt!="")
            ui->label_125_3->setText(Textprompt);

        if(Display==1)
        {
            ui->widget_145->show();
        }else if(Display==0)
        {
            ui->widget_145->hide();
        }
        break;
    }
    case -1:
    {
        ui->label_CPU->setText(QString("%1 %").arg(Text));
        int t=Text.toInt();
        int c=config.CPULack.toInt();
        qDebug()<<"label_CPU"<<t<<c;
        if(t>c)
        {
            CPUAbnormalNum++;
            qDebug()<<"CPU预制";
        }
        else
        {
            CPUAbnormalNum=0;
            qDebug()<<"CPU";
        }
        if(CPUAbnormalNum>10)
        {

            //隐藏播放语音
            if(IsCallPolice)

            {
                if (MediaPlayer->state() == QMediaPlayer::PlayingState) {
                    // 已经在播放
                    qDebug()<<"已经在播放";
                } else {
                    // 不在播放
                    CallPoliceInfo="CPU异常";
                    QString styleSheet = QString("QLabel { border-image: url(:/new/prefix1/ICON/报警2.png) left bottom no-repeat; }");
                    ui->label_CALLIcon->setStyleSheet(styleSheet);
                    MediaPlayer->setMedia(QUrl::fromLocalFile(QString("%1/WarningSound.mp3").arg(currentPath)));
                    MediaPlayer->setVolume(50); // 设置音量，可以根据需要调整
                    MediaPlayer->play();
                }

            }
        }
        else
        {
            QString styleSheet = QString("QLabel { border-image: url(:/new/prefix1/ICON/报警1.png) left bottom no-repeat; }");
            ui->label_CALLIcon->setStyleSheet(styleSheet);
            MediaPlayer->stop();
            CallPoliceInfo="";
        }

        QDateTime currentTime = QDateTime::currentDateTime();
        QString currentTimeStr = currentTime.toString("hh:mm:ss\nyyyy/MM/dd");
        ui->label_Time->setText(currentTimeStr);
        break;
    }

    case -2:
    {
        ui->label_MEMORY->setText(Text);

        break;
    }
    case -3:
    { int c=config.MemoryLack.toInt();
        qDebug()<<"MemoryLack"<<c;

        ui->label_DISK->setText(Text);
        int slashIndex = Text.indexOf('/'); // 查找 '/' 的位置
        if (slashIndex != -1) { // 确保找到了 '/'
            FreeGB = Text.left(slashIndex).toDouble(); // 截取 '/' 之前的部分
            if((FreeGB*1000)<=c)
            {
                //隐藏播放语音
                if(IsCallPolice)
                {
                    if (MediaPlayer->state() == QMediaPlayer::PlayingState) {
                        // 已经在播放
                        qDebug()<<"已经在播放";
                    } else {
                        CallPoliceInfo="磁盘空间达到阈值";
                        MediaPlayer->stop();
                        CallPoliceInfo="";
                        QString styleSheet = QString("QLabel { border-image: url(:/new/prefix1/ICON/报警2.png) left bottom no-repeat; }");
                        ui->label_CALLIcon->setStyleSheet(styleSheet);
                        MediaPlayer->setMedia(QUrl::fromLocalFile(QString("%1/WarningSound.mp3").arg(currentPath)));
                        MediaPlayer->setVolume(50); // 设置音量，可以根据需要调整
                        MediaPlayer->play();
                    }
                }
            }
            else
            {
                QString styleSheet = QString("QLabel { border-image: url(:/new/prefix1/ICON/报警1.png) left bottom no-repeat; }");
                ui->label_CALLIcon->setStyleSheet(styleSheet);
                MediaPlayer->stop();
                CallPoliceInfo="";
            }

        } else {
            qDebug() << "No slash found in the string.";
        }
        break;
    }

    case -4:
    {
        IP=getNetworkIP();
        if(IP=="")
        {
            //隐藏播放语音
            if(IsCallPolice)
            {
                if (MediaPlayer->state() == QMediaPlayer::PlayingState) {
                    // 已经在播放
                    qDebug()<<"已经在播放";
                } else {
                    CallPoliceInfo="网络已断开";
                    QString styleSheet = QString("QLabel { border-image: url(:/new/prefix1/ICON/报警2.png) left bottom no-repeat; }");
                    ui->label_CALLIcon->setStyleSheet(styleSheet);
                    MediaPlayer->setMedia(QUrl::fromLocalFile(QString("%1/WarningSound.mp3").arg(currentPath)));
                    MediaPlayer->setVolume(50); // 设置音量，可以根据需要调整
                    MediaPlayer->play();
                }
            }
        }
        else
        {
            QString styleSheet = QString("QLabel { border-image: url(:/new/prefix1/ICON/报警1.png) left bottom no-repeat; }");
            ui->label_CALLIcon->setStyleSheet(styleSheet);
            MediaPlayer->stop();
            CallPoliceInfo="";
        }
        ui->label_NETWORK->setText(Text);

        break;
    }

    case -5:
    {

        QStringList splitText = Text.split("*/");
        Announcement announcement;
        for (int i = 0; i < splitText.size(); ++i) {
            const QString& substring = splitText.at(i);
            if (i == 0) {
                ui->textBrowser->setPlainText(substring);
                announcement.AnnouncementTitle = substring;

            }
            else if(i == 1) {
                announcement.AnnouncementContent = substring;
            }
            else if(i == 2) {
                announcement.AnnouncementTime = substring;
            }
            else if(i == 3) {
            }
            announcement.AnnouncementCc = substring;

        }
        Notice.push_back(announcement);
        break;
        break;
    }

    case -6:
    {

        //ui->textBrowser_message->setPlainText(Text);
        break;

    }

    default:
    {
        break;
    }

    }
    //qDebug()<<"SetLabel1";
    return true;

}

//void MainWindow::Refresh()
//{
//    QString Row="";
//    QString List="";
//    config.ReadRouteInfo("config_record.ini","Row",Row);
//    config.ReadRouteInfo("config_record.ini","List",List);

//    row=Row.toInt();
//    column=List.toInt();

//    for(int i=1;i<=SYSTEMROW*SYSTEMLIST;++i)
//    {
//        QString value="";
//        if(config.ReadRouteInfo("config_route.ini",QString("Initalize_%1").arg(i),value))//已经获取的路径文件
//        {
//            if(value!="")
//            {
//                IsALLlist[i]=true;
//                TemporaryPath[i]=value;
//            }
//            else
//            {
//                IsALLlist[i]=false;
//                TemporaryPath[i]="";
//            }

//        }
//    }

//    calculateNumbers(row,column);//
//}

void MainWindow::on_pushButton_audio1_clicked()
{
    QFileDialog fileDialog(this);
    fileDialog.setAcceptMode(QFileDialog::AcceptOpen);
    //将文件对话框的标题设置为“打开文件”。
    fileDialog.setWindowTitle(tr("Open Files"));
    //中检索支持的 MIME 类型的列表
    QStringList supportedMimeTypes = pPlayeAudio->supportedMimeTypes();
    // 设置文件选择模式为多选模式
    fileDialog.setFileMode(QFileDialog::ExistingFiles);
    fileDialog.setDirectory(QStandardPaths::standardLocations(QStandardPaths::MoviesLocation).value(0, QDir::homePath()));
    if (fileDialog.exec() == QDialog::Accepted)
    {//获取用户选择的文件的路径列表。
        QStringList selectedFiles = fileDialog.selectedFiles();
        if (!selectedFiles.isEmpty()) {
            //把选择的加入列表
            ui->listWidget->addItems(selectedFiles);
            // 遍历选中的路径
            for (const QString& filePath : selectedFiles) {
                qDebug() << filePath;
                QUrl url(filePath);
                QStringList videoFormats = {"wav"};
                QString fileExtension = url.fileName().section('.', -1);
                if (videoFormats.contains(fileExtension, Qt::CaseInsensitive)) { // 判断是否为视频
                    pPlayAudiolist->addMedia(url); // 加入到播放列表中
                }
            }
        }
    }
    int item = pPlayAudiolist->mediaCount(); // Get the number of media items in the playlist

    for (int i = 0; i < item; i++) {
        QMediaContent media = pPlayAudiolist->media(i); // Get the media item at the specified index
        QUrl url = media.request().url(); // Get the URL of the media item

        // Output the URL or perform any desired operations
        qDebug() << url;
    }

    isOpen1=true;
}

void MainWindow::on_pushButton_audio2_clicked()
{

    int itemCount = ui->listWidget->count();//获取数量
    int nextVideoIndex = -1;
    for (int i = 0; i < itemCount; i++) {
        QListWidgetItem* item = ui->listWidget->item(i);
        QString path = item->text(); // 获取路径文本
        QUrl url(path);
        QStringList videoFormats = {"wav"};
        QString fileExtension = url.fileName().section('.', -1);
        if (videoFormats.contains(fileExtension, Qt::CaseInsensitive)) {// 判断是否为视频
            nextVideoIndex = i;
            break;
        }
    }
    QList<QListWidgetItem*> selectedItems = ui->listWidget->selectedItems();
    if (!selectedItems.isEmpty()) {
        foreach (QListWidgetItem* item, selectedItems) {
            QString path = item->text(); // Assuming the path is stored as text in each item
            //选中的音频播放加入到队列中
            QUrl url(path);
            QStringList videoFormats = {"wav"}; // Add more video formats if needed
            QString fileExtension = url.fileName().section('.', -1);
            if (videoFormats.contains(fileExtension, Qt::CaseInsensitive)) {
                int itempPlay = pPlayAudiolist->mediaCount(); // Get the number of media items in the playlist
                for (int j = 0; j < itempPlay; j++) {
                    QMediaContent media = pPlayAudiolist->media(j); // Get the media item at the specified index
                    if(url == media.request().url())
                    {// Get the URL of the media item
                        pPlayAudiolist->setCurrentIndex(j);
                        break;
                    }
                }
                qDebug() << "1"<<url;
                // Play the selected video
                //                pPlayeAudio->stop(); // Stop any ongoing playback
                //                pPlayeAudio->setMedia(url);
                //pAudio->resize(ui->audio->size());//设置成标签大小
                //pViedo->setGeometry(ui->video->geometry()); // Set the video widget geometry
                ui->listWidget->setCurrentItem(item);
                //调用进程处理，暂停视频按钮
                this->process->write("quit\n");
                // Play the selected video
                play(url.toString(),ui->widget_57->winId());
                // pPlayeAudio->play();
                break;
            }
            else if (nextVideoIndex != -1) {
                pPlaylist->setCurrentIndex(0);

                QMediaContent media = pPlaylist->media(0); // Get the media item at the specified index
                QUrl url = media.request().url(); // Get the URL of the media item
                //                pPlayeAudio->stop(); // Stop any ongoing playback
                //                pPlayeAudio->setMedia(url);
                // pAudio->resize(ui->audio->size());//设置成标签大小
                // Get the corresponding list item
                QListWidgetItem* nextVideoItem = ui->listWidget->item(nextVideoIndex);

                // Set the selected item in the list widget
                ui->listWidget->setCurrentItem(nextVideoItem);//设置当前列表指向
                //调用进程处理，暂停视频按钮
                this->process->write("quit\n");
                // Play the selected video
                qDebug() << "2"<<url;
                play(url.toString(),ui->widget_57->winId());
                // Play the video
                //pPlayeAudio->play();
            }
        }


    }
    else if (nextVideoIndex != -1) {
        pPlaylist->setCurrentIndex(0);

        QMediaContent media = pPlaylist->media(0); // Get the media item at the specified index
        QUrl url = media.request().url(); // Get the URL of the media item
        //        pPlayeAudio->stop(); // Stop any ongoing playback
        //        pPlayeAudio->setMedia(url);
        //pAudio->resize(ui->audio->size());//设置成标签大小
        // Get the corresponding list item
        QListWidgetItem* nextVideoItem = ui->listWidget->item(nextVideoIndex);

        // Set the selected item in the list widget
        ui->listWidget->setCurrentItem(nextVideoItem);//设置当前列表指向
        //调用进程处理，暂停视频按钮
        this->process->write("quit\n");
        // Play the selected video
        qDebug() << "3"<<url;
        play(url.toString(),ui->widget_57->winId());
        // Play the video
        // pPlayeAudio->play();
    }
}
void MainWindow::on_pushButton_audio3_clicked()
{
    // pPlayeAudio->pause();
    //调用进程处理，暂停视频按钮
    this->process->write("quit\n");
}

void MainWindow::on_pushButton_audio4_clicked()
{
    pPlayeAudio->stop();
}
void MainWindow::onMediaStatusChanged_Audio(QMediaPlayer::MediaStatus status)
{
    if (status == QMediaPlayer::EndOfMedia) {
        // 当前视频播放完毕，继续进行播放
        getNextAudioAndPlay();
    }
}
//播放结束循环播放
void MainWindow::getNextAudioAndPlay()
{

    QList<QListWidgetItem*> selectedItems = ui->listWidget->selectedItems();
    if (!selectedItems.isEmpty()) {
        foreach (QListWidgetItem* item, selectedItems) {
            QString path = item->text(); // Assuming the path is stored as text in each item
            //选中的音频播放加入到队列中
            QUrl url(path);
            QStringList videoFormats = {"mp4", "avi", "mkv", "mov"}; // Add more video formats if needed
            QString fileExtension = url.fileName().section('.', -1);
            if (videoFormats.contains(fileExtension, Qt::CaseInsensitive)) {
                // Play the selected video
                //                pPlayeAudio->stop(); // Stop any ongoing playback
                //                pPlayeAudio->setMedia(url);
                //pAudio->resize(ui->audio->size());//设置成标签大小
                //pAudio->setGeometry(ui->audio->geometry()); // Set the audio widget geometry
                ui->listWidget->setCurrentItem(item);
                //pPlayeAudio->play();
                //调用进程处理，暂停视频按钮
                this->process->write("quit\n");
                // Play the selected video
                play(url.toString(),ui->widget_57->winId());
                break;
            }
            else
            {
                //如果不是视频，自动获取下一个是视频格式的进行播放
                //int nextIndex = -1;
                int currentIndex = ui->listWidget->row(item);
                int itemCount = ui->listWidget->count();
                for (int i = currentIndex + 1; i < itemCount; i++) {
                    QListWidgetItem* nextItem = ui->listWidget->item(i);
                    QString nextPath = nextItem->text();
                    QUrl nextUrl(nextPath);
                    QString nextFileExtension = nextUrl.fileName().section('.', -1);

                    if (videoFormats.contains(nextFileExtension, Qt::CaseInsensitive)) {
                        // Play the selected audio
                        //                        pPlayeAudio->stop(); // Stop any ongoing playback
                        //                        pPlayeAudio->setMedia(url);
                        //pAudio->resize(ui->audio->size());//设置成标签大小
                        // pAudio->setGeometry(ui->audio->geometry()); // Set the audio widget geometry
                        ui->listWidget->setCurrentItem(nextItem);
                        // pPlayeAudio->play();
                        //调用进程处理，暂停视频按钮
                        this->process->write("quit\n");
                        // Play the selected video
                        play(url.toString(),ui->widget_57->winId());
                        //nextIndex = i; // Update the next index for future iterations
                        break;
                    }

                }
            }
        }
    }
    else
    {


    }

}

//void MainWindow::on_horizontalSlider_audio1_valueChanged(int value)
//{
//    pPlayeAudio->setPosition((qint64)value);
//    // Get the current playback time in seconds
//    qint64 currentPosition = pPlayeAudio->position() / 1000;
//    // Get the total video duration in seconds
//    qint64 totalDuration = pPlayeAudio->duration() / 1000;

//    // Format the current playback time and total video time
//    QString currentTimeString = QTime(0, 0).addSecs(currentPosition).toString("hh:mm:ss");
//    QString totalTimeString = QTime(0, 0).addSecs(totalDuration).toString("hh:mm:ss");

//    // Update the schedulelabel to display the current playback time and total video time
//    QString scheduleText = currentTimeString + " / " + totalTimeString;
//    ui->schedulelabel1->setText(scheduleText);
//}

//void MainWindow::on_horizontalSlider_audio2_valueChanged(int value)
//{
//    pPlayeAudio->setVolume(value);
//    // Update the volumelabel to display the volume percentage
//    QString volumeText = QString::number(value) + "%";
//    ui->volumelabel1->setText(volumeText);


//}

void MainWindow::on_pushButton_11_clicked()
{
    QString text;
    int itemCount = ui->listWidget->count();//获取数量
    for (int i = 0; i < itemCount; i++) {
        QListWidgetItem* item = ui->listWidget->item(i);
        QString path = item->text(); // 获取路径文本
        if(decryptFile(path,"TCL123"))
        {
            text=QString("%1:解密完成！").arg(path);
            //ui->textBrowser_message->append(text);
            qDebug() <<path<<"解密完成！";
        }
        else
        {
            text=QString("%1:解密失败！").arg(path);
            //ui->textBrowser_message->append(text);
            qDebug() <<path<<"解密失败！";
        }
    }
}

void MainWindow::on_pushButton_keep_clicked()
{
    //config.UpdateRouteValueInfo("config_record.ini","TCL_C8",QString("%1").arg(ui->TCL_C8->isChecked()));
    StayScreen=4;//停留界面
    ui->stackedWidget->setCurrentWidget(ui->page_4);//切换页面
}

void MainWindow::on_pushButton_12_clicked()
{
    ui->tableWidget_2->selectAll();
    //c();
    //    config.ReadInfo("config.ini","ServerAddress",ServerAddress);
    //    config.ReadInfo("config.ini","ServerPor",ServerPor);
    //    // 检查插座是否已连接或已连接
    //    if (ClientSocket->state() == QAbstractSocket::UnconnectedState) {
    //        // 套接字未连接，请启动连接
    //        ClientSocket->setProxy(QNetworkProxy::NoProxy);
    //        ClientSocket->connectToHost(ServerAddress, ServerPor.toUShort());
    //        config.WriteInfo("正在连接服务器");
    //    } else {
    //        // Socket is already connecting or connected, ignore the button click
    //        qDebug() << "连接正在进行，请先断开连接！";
    //        config.WriteInfo("连接正在进行，请先断开连接！");
    //    }
    //    // Check if the socket is already connecting or connected
}


void MainWindow::on_pushButton_17_clicked()
{
    ui->TCL_01->isChecked();
    qDebug()<<"on_pushButton_17_clicked";
    ui->stackedWidget->setCurrentWidget(ui->page);//切换页面
}
void MainWindow::a()
{
    ui->comboBox_department->clear();
    // Add new items
    ui->comboBox_department->addItem("Item 1");
    ui->comboBox_department->addItem("Item 2");
    ui->comboBox_department->addItem("Item 3");

}
void MainWindow::b(QString Path)
{
    config.filelist.clear();
    config.findFilesByCreationDateAotu(Path);

    int i=0;
    //    for(int j=0;j<lastNum;j++)
    //    {
    //        delete item[j];
    //        delete item1[j];
    //    }

    //遍历所有控件状态
    for (auto& deviceInfo : config.filelist) {
        int nCount=ui->tableWidget_2->rowCount();
        if(nCount<=i)
        {
            ui->tableWidget_2->insertRow(i);
        }
        qDebug()<<"加入"<<deviceInfo.fileName;
        item[i]= new QTableWidgetItem(QString("%1").arg(deviceInfo.fileName));
        ui->tableWidget_2->setItem(i,0,item[i]);
        item1[i]= new QTableWidgetItem(QString("%1").arg(deviceInfo.lastModified));
        ui->tableWidget_2->setItem(i,1,item1[i]);
        item2[i]= new QTableWidgetItem(QString("否"));
        ui->tableWidget_2->setItem(i,2,item2[i]);
        i++;

    }
    lastNum=i;
}
void MainWindow::c()
{
    foreach (const QTableWidgetSelectionRange &range, ui->tableWidget_2->selectedRanges()) {
        for(int i= range.topRow();i<=range.bottomRow();++i){
            qDebug()<<i;
        }
    }

}
void MainWindow::on_pushButton_16_clicked()
{
    qDebug()<<"on_pushButton_17_clicked";
    ui->stackedWidget->setCurrentWidget(ui->page);//切换页面
}

void MainWindow::on_pushButton_18_clicked()
{
    qDebug()<<"on_pushButton_18_clicked";
    ui->stackedWidget->setCurrentWidget(ui->page);//切换页面
}
void MainWindow::Startkeyboard()
{
    //不会阻塞程序
    QString processName = QString("onboard");
    QProcess process;
    process.startDetached(processName);
}
void MainWindow::handleDeviceEvent(int socket) {


    //    struct udev_device* dev = udev_monitor_receive_device(monitor);
    //    if (dev) {
    //        const char* action = udev_device_get_action(dev);
    //        const char* devicePath = udev_device_get_devnode(dev);

    //        if (action && devicePath) {
    //            if (strcmp(action, "add") == 0) {
    //                qDebug() << "Device added:" << devicePath;
    //                // Output device information
    //                                //const char* deviceName = udev_device_get_sysattr_value(dev, "name");
    //                                const char* vendorId = udev_device_get_sysattr_value(dev, "idVendor");
    //                                const char* productId = udev_device_get_sysattr_value(dev, "idProduct");
    //                                const char* manufacturer = udev_device_get_sysattr_value(dev, "manufacturer");
    //                                const char* product = udev_device_get_sysattr_value(dev, "product");
    //                                  const char* serial = udev_device_get_sysattr_value(dev, "serial");
    //                                const char* syspath = udev_device_get_syspath(dev);
    //                                const char* devpath = udev_device_get_devpath(dev);

    //                                // Additional information
    //                                const char* bus = udev_device_get_sysattr_value(dev, "busnum");
    //                                const char* device = udev_device_get_sysattr_value(dev, "devnum");
    //                                //const char* id = udev_device_get_sysattr_value(dev, "idnum");

    //                                //qDebug() << "Device Name:" << (deviceName ? deviceName : "N/A");
    //                                qDebug() << "Vendor ID:" << (vendorId ? vendorId : "N/A");
    //                                qDebug() << "Product ID:" << (productId ? productId : "N/A");
    ////                                    qDebug() << "Syspath:" << (syspath ? syspath : "N/A");
    ////                                    qDebug() << "Devpath:" << (devpath ? devpath : "N/A");
    //                                qDebug() << "Bus:" << (bus ? bus : "N/A");
    //                                qDebug() << "Device:" << (device ? device : "N/A");
    //                                //qDebug() << "ID:" << (id ? id : "N/A");
    //                                qDebug() << "manufacturer:" << (manufacturer ? manufacturer : "N/A");
    //                                qDebug() << "product:" << (product ? product : "N/A");
    //                                qDebug() << "serial:" << (serial ? serial : "N/A");
    //            } else if (strcmp(action, "remove") == 0) {
    //                qDebug() << "Device removed:" << devicePath;
    //            }
    //        }

    //        udev_device_unref(dev);
    //    }
}
MainWindow::~MainWindow()
{
    //  udev_unref(udev);
    delete ui;
}

void MainWindow::on_pushButton_13_clicked()
{
    ui->tableWidget_2->clearSelection();
}

void MainWindow::on_pushButton_19_clicked()
{
    c();
}

//void MainWindow::on_pushButton_20_clicked()
//{
//    QDateTime StartTime= ui->dateTimeEdit_3->dateTime();
//    QDateTime EndTime= ui->dateTimeEdit_4->dateTime();
//    ui->comboBox_department->currentIndex();
//    ui->comboBox_department->currentText();
//            // ui->comboBox->setCurrentIndex(-1);
//    QString StartDatetime=StartTime.toString("yyyyMMddhhmmss");
//    QString EnDatetime=EndTime.toString("yyyyMMddhhmmss");
//    int Index=ui->comboBox_department->currentIndex();
//    QJsonObject jsonObject;
//    jsonObject["StartTime"] = StartDatetime;
//    jsonObject["EndTime"] = EnDatetime;
//        jsonObject["Index"] = Index;
//    Send(ACQUISITION_STATION,POLICE_SITUATION_INQUIRY_C,jsonObject);
//}

void MainWindow::on_pushButton_query_clicked()
{
    QDateTime StartTime= ui->dateTimeEdit_3->dateTime();
    QDateTime EndTime= ui->dateTimeEdit_4->dateTime();
    ui->comboBox_department->currentIndex();
    ui->comboBox_department->currentText();
    // ui->comboBox->setCurrentIndex(-1);
    QString StartDatetime=StartTime.toString("yyyyMMddhhmmss");
    QString EnDatetime=EndTime.toString("yyyyMMddhhmmss");
    int Index=ui->comboBox_department->currentIndex();
    QJsonObject jsonObject;
    jsonObject["StartTime"] = StartDatetime;
    jsonObject["EndTime"] = EnDatetime;
    jsonObject["Index"] = Index;
    jsonObject["UserID"] = ui->label_userid->text();
    Send(ACQUISITION_STATION,POLICE_SITUATION_INQUIRY_C,jsonObject);
}



void MainWindow::on_pushButton_referto_clicked()
{
    bool Isfile_type=true;
    bool IsWarn=true;
    //    QTableWidgetItem *itemToModify=ui->tableWidget_2->item(1,2);
    //    itemToModify->setText("是");
    //itemToModify->setBackground(QBrush(Qt::lightGray));
    foreach (const QTableWidgetSelectionRange &range, ui->tableWidget_2->selectedRanges()) {
        for(int i= range.topRow();i<=range.bottomRow();++i){
            {

                QTableWidgetItem *itemToModify=ui->tableWidget_2->item(i,2);
                if(itemToModify->text()=="是")
                {
                    QMessageBox::critical(nullptr, "错误", "已经有绑定的文件");
                    return;
                }
            }
        }
    }
    foreach (const QTableWidgetSelectionRange &range, ui->tableWidget_3->selectedRanges()) {
        for(int j= range.topRow();j<=range.bottomRow();++j){
            QTableWidgetItem *itemToModify=ui->tableWidget_3->item(j,4);
            if(itemToModify->text()=="是")
            {
                QMessageBox::critical(nullptr, "错误", "已经有绑定的警情");
                return;
            }
        }
    }
    foreach (const QTableWidgetSelectionRange &range, ui->tableWidget_2->selectedRanges()) {
        for(int i= range.topRow();i<=range.bottomRow();++i){
            BindingInfo bindinginfo;
            QTableWidgetItem *itemToModify=ui->tableWidget_2->item(i,2);

            itemToModify->setText("是");
            bindinginfo.fileid=i;
            bindinginfo.fileSize=config.filelist[i].fileSize;
            bindinginfo.fileName=config.filelist[i].fileName;
            bindinginfo.lastModified=config.filelist[i].lastModified;
            bindinginfo.sourceFilePath=config.filelist[i].sourceFilePath;
            bindinginfo.officerID=config.filelist[i].officerID;
            bindinginfo.productNumber=config.filelist[i].productNumber;
            int Index=ui->comboBox_filetype->currentIndex();
            if(Index>0)
            {
                bindinginfo.file_type_id=Filetype[Index-1].ID;
                bindinginfo.file_type=Filetype[Index-1].Name;
                qDebug()<<"Index="<<Index-1<<"<Filetype[Index].Name="<<Filetype[Index-1].Name;
            }
            else
            {
                Isfile_type=false;

                bindinginfo.file_type="";
            }
            /*foreach (const QTableWidgetSelectionRange &range, ui->tableWidget_3->selectedRanges()) {
                            for(int j= range.topRow();j<=range.bottomRow();++j){*/
            int j=ui->tableWidget_3->currentRow();
            if(j<1)
            {
                IsWarn=false;


            }
            else{
                QTableWidgetItem *itemToModify1=ui->tableWidget_3->item(j,4);
                bindinginfo.winfoid=j;
                itemToModify1->setText("是");
                bindinginfo.winfo.alarm_time_text=PoliceInfo[j].alarm_time_text;
                bindinginfo.winfo.call_police_time=PoliceInfo[j].call_police_time;
                bindinginfo.winfo.happen_address=PoliceInfo[j].happen_address;
                bindinginfo.winfo.case_desc=PoliceInfo[j].case_desc;
                bindinginfo.winfo.unit_number=PoliceInfo[j].unit_number;
                bindinginfo.winfo.case_number=PoliceInfo[j].case_number;
                bindinginfo.winfo.trafficCaseTable=PoliceInfo[j].trafficCaseTable;
                qDebug()<<"j="<<j<<"PoliceInfo[j].trafficCaseTable="<<PoliceInfo[j].trafficCaseTable;
            }
            BindList.push_back(bindinginfo);
            qDebug()<<i;
        }
    }
    if(!IsWarn)
    {   QMessageBox::critical(nullptr, "提示", "未绑定的警情");}
    if(!Isfile_type)
    {   QMessageBox::critical(nullptr, "提示", "未绑定的文件类型");}
}

void MainWindow::on_pushButton_cancel_clicked()
{
    foreach (const QTableWidgetSelectionRange &range, ui->tableWidget_3->selectedRanges()) {
        for(int i= range.topRow();i<=range.bottomRow();++i){
            QTableWidgetItem *itemToModify=ui->tableWidget_3->item(i,0);
            QTableWidgetItem *itemToModify1=ui->tableWidget_3->item(i,4);
            itemToModify1->setText("否");
            for(auto it=BindList.begin();it!=BindList.end();){
                qDebug()<<" itemToModify->text()"<<itemToModify->text();
                qDebug()<<" it->winfo[0].case_number"<<it->winfo.case_number;
                if(it->winfo.case_number== itemToModify->text()&&ui->tableWidget_3->currentRow()==it->winfoid)
                {
                    int rewCound=ui->tableWidget_2->rowCount();
                    qDebug()<<" qDebug()<<"<<rewCound;
                    //foreach (const QTableWidgetSelectionRange &range, ui->tableWidget_2->selectedItems()) {
                    for(int j= 0;j<rewCound;++j){
                        QTableWidgetItem *itemToModify2=ui->tableWidget_2->item(j,0);
                        if(it->fileName==itemToModify2->text()&&it->fileid==j)
                        {
                            QTableWidgetItem *itemToModify3=ui->tableWidget_2->item(j,2);
                            itemToModify3->setText("否");
                        }

                    }
                    //}
                    qDebug()<<it->fileName;
                    it=BindList.erase(it);
                }
                else
                {
                    ++it;
                }

            }
            qDebug()<<i;
        }
    }

    //    bindinginfo.fileName="";
    //    bindinginfo.lastModified="";
    //    bindinginfo.sourceFilePath="";
    //    bindinginfo.officerID="";
    //    bindinginfo.productNumber="";
    //    for(int j=0;j<10;j++)
    //    {
    //        bindinginfo.winfo[j].alarm_time_text="";
    //        bindinginfo.winfo[j].call_police_time="";
    //        bindinginfo.winfo[j].happen_address="";
    //        bindinginfo.winfo[j].case_desc="";
    //        bindinginfo.winfo[j].unit_number="";
    //        bindinginfo.winfo[j].case_number="";
    //    }
}
void MainWindow::on_label_WOKIcon_Clicked()
{
    // 在这里添加显示具体内容的代码
    // 例如，更新一个文本编辑框或显示一个对话框等
    IP="";
    IP=getNetworkIP();
    QString content = QString("IP: %1").arg(IP);
    QString content2 = QString("授权码: %1").arg(authorize_code);
    QString   machineCodeDisplay  = QString("MAC: %2").arg(mac);

    // 构建HTML内容，注意闭合括号
    QString htmlContent = QString("<p align='justify'>%1</p><p align='right'>%2</p><p align='right'>%3</p>").arg(content, machineCodeDisplay, content2);


    QMessageBox::information(this, tr("网络信息"), htmlContent);
}
void MainWindow::on_label_CALLIcon_Clicked()
{

    if(IsCallPolice)
    {
        int ret = QMessageBox::question(this, tr("提示"),
                                        QString("确定取消报警消息？当前异常为：%1").arg(CallPoliceInfo),
                                        QMessageBox::Yes | QMessageBox::No);
        if (ret == QMessageBox::Yes) {
            IsCallPolice=false;
            if (MediaPlayer->state() == QMediaPlayer::PlayingState) {
                // 已经在播放
                qDebug()<<"已经在播放";
                //设置任务图标
                QString styleSheet = QString("QLabel { border-image: url(:/new/prefix1/ICON/报警1.png) left bottom no-repeat; }");
                ui->label_CALLIcon->setStyleSheet(styleSheet);
                MediaPlayer->stop();
            } else {
                QString styleSheet = QString("QLabel { border-image: url(:/new/prefix1/ICON/报警1.png) left bottom no-repeat; }");
                ui->label_CALLIcon->setStyleSheet(styleSheet);
            }
            // 用户点击了“是”按钮
        }
    }
    else
    {
        int ret = QMessageBox::question(this, tr("提示"),
                                        tr("确定开启报警消息？"),
                                        QMessageBox::Yes | QMessageBox::No);
        if (ret == QMessageBox::Yes) {
            QString styleSheet = QString("QLabel { border-image: url(:/new/prefix1/ICON/报警1.png) left bottom no-repeat; }");
            ui->label_CALLIcon->setStyleSheet(styleSheet);
            IsCallPolice=true;
            // 用户点击了“是”按钮
        }
    }
}
void MainWindow::on_pushButton_warnupload_clicked()
{

    QJsonObject jsonObject;
    QJsonArray jsoncategoryArray;
    qint64 file_AllSize=0;
    for(auto it=BindList.begin();it!=BindList.end();){
        QJsonObject Bind_list;
        file_AllSize+=it->fileSize;
        Bind_list["file_size"] = it->fileSize;
        Bind_list["lastModified"] = it->lastModified;
        Bind_list["file_type_id"] = it->file_type_id;
        Bind_list["fileName"] = it->fileName;
        Bind_list["sourceFilePath"] = it->sourceFilePath;
        Bind_list["case_number"] = it->winfo.case_number;
        Bind_list["trafficCaseTable"] = it->winfo.trafficCaseTable;
        jsoncategoryArray.append(Bind_list);
        ++it;
    }
    jsonObject["file_AllSize"] = file_AllSize;
    jsonObject["SerialPort"] = SerialPort;
    jsonObject["Bind_list"] = jsoncategoryArray;
    qDebug()<<jsoncategoryArray;



    Send(ACQUISITION_STATION,POLICE_SITUATION_UPLOAD_C,jsonObject);

}

void MainWindow::on_pushButton_save6_clicked()
{
    //    MemoryLack=ui->label_ram->text();
    //    CPULack=ui->label_cpu->text();
    //    BackgroundVersion=ui->label_backversion->text();
    //    TheLocalKey=ui->label_accountnum->text();
    //    TheLocalKeyPDW=ui->label_passwd->text();
    //    //MUI=ui->label_languagepack->textChanged();
    //    MUI=ui->label_languagepack->text();
    //    URL=ui->label_backurl->text();
    //    MountUrl=ui->label_multidiskmount->text();
    //    Camera=ui->label_camera->text();
    //    FingerPrint=ui->label_fingermark->text();
    //    FaceRecognition=ui->label_face->text();
    //    DeleteFiles=ui->label_deletevideo->text();


    config.UpdateInfo("config.ini","MemoryLack",ui->label_ram->text());//内存不足报警
    config.UpdateInfo("config.ini","CPULack",ui->label_cpu->text());//内存不足报警
    config.UpdateInfo("config.ini","BackgroundVersion",ui->label_backversion->text());//内存不足报警
    config.UpdateInfo("config.ini","TheLocalKey",ui->label_accountnum->text());//内存不足报警
    config.UpdateInfo("config.ini","TheLocalKeyPDW",ui->label_passwd->text());//内存不足报警
    config.UpdateInfo("config.ini","MUI",ui->label_languagepack->text());//内存不足报警
    config.UpdateInfo("config.ini","URL",ui->label_backurl->text());//内存不足报警
    config.UpdateInfo("config.ini","MountUrl",ui->label_multidiskmount->text());//内存不足报警
    config.UpdateInfo("config.ini","Camera",ui->label_camera->text());//内存不足报警
    config.UpdateInfo("config.ini","FingerPrint",ui->label_fingermark->text());//内存不足报警
    config.UpdateInfo("config.ini","FaceRecognition",ui->label_face->text());//内存不足报警
    config.UpdateInfo("config.ini","DeleteFiles",ui->label_deletevideo->text());//内存不足报警
    StayScreen=0;
    ui->stackedWidget->setCurrentWidget(ui->page);//切换页面

}

void MainWindow::on_pushButton_exit6_clicked()
{
    StayScreen=0;
    ui->stackedWidget->setCurrentWidget(ui->page);//切换页面
}

void MainWindow::on_pushButton_warnexit_clicked()
{
    StayScreen=0;
    ui->stackedWidget->setCurrentWidget(ui->page);//切换页面
}

void MainWindow::on_horizontalSlider_sliderMoved(int position)
{
    qDebug()<<"sliderMoved"<<position;
    QString command=QString("seek %1 2\n").arg(position);
    //  this->process->write(command.toUtf8());
    //    QString command=QString("seek %1 3\n").arg(position);
    //      this->process->write(command.toUtf8());
}


void MainWindow::on_horizontalSlider_2_sliderMoved(int position)
{
    //调用进程处理声音控制进度条的走势,进程处理(maplyer）
    qDebug()<<"slidermoved"<<position;

    this->process->write(QString("volume " + QString::number(position) +" 2\n").toUtf8());
}

void MainWindow::on_horizontalSlider_audio1_sliderMoved(int position)
{
    qDebug()<<"slidermoved"<<position;
    QString command=QString("seek %1 2\n").arg(position);
    this->process->write(command.toUtf8());
}

void MainWindow::on_pushButton_audio5_clicked()
{
    //上一个

    int currentIndex = pPlayAudiolist->currentIndex();
    int previousIndex = currentIndex - 1;
    // 查找上面没有回到最后
    if (previousIndex < 0) {
        previousIndex = pPlayAudiolist->mediaCount() - 1;
    }

    QMediaContent media = pPlayAudiolist->media(previousIndex); // Get the media item at the specified index
    QUrl url = media.request().url(); // Get the URL of the media item
    //    pPlaye->stop();
    //    pPlaye->setMedia(url);
    // pViedo->resize(ui->widget_55->size());//设置成标签大小
    pPlayAudiolist->setCurrentIndex(previousIndex);
    //调用进程处理，暂停视频按钮
    this->process->write("quit\n");
    // Play the selected video
    play(url.toString(),ui->widget_57->winId());
    //    // Play the video
    //    pPlaye->play();
    // 在控件 ui->listWidget 中查找并选中值为指定值的行
    QString valueToFind =url.toString();
    Qt::MatchFlags flags = Qt::MatchExactly; // 精确匹配标志
    QList<QListWidgetItem *> foundItems = ui->listWidget->findItems(valueToFind.replace(0, 1, valueToFind.at(0).toUpper()), flags);
    // 遍历找到的项
    for (QListWidgetItem* item : foundItems) {
        // 处理找到的项
        // 例如，访问项的文本或其他属性
        QString itemText = item->text();
        qDebug() << itemText;
        ui->listWidget->setCurrentItem(item);
    }



}
//下一个

void MainWindow::on_pushButton_audio7_clicked()
{
    int currentIndex = pPlayAudiolist->currentIndex();
    int nextIndex = currentIndex + 1;
    // Find the next valid video index
    int itemCount = pPlayAudiolist->mediaCount();
    if (nextIndex >= itemCount) {
        nextIndex = 0;
    }
    QMediaContent media = pPlayAudiolist->media(nextIndex); // Get the media item at the specified index
    QUrl url = media.request().url(); // Get the URL of the media item
    //    pPlaye->stop();
    //    pPlaye->setMedia(url);
    //pViedo->resize(ui->widget_55->size());//设置成标签大小
    pPlayAudiolist->setCurrentIndex(nextIndex);
    //调用进程处理，暂停视频按钮
    this->process->write("quit\n");
    // Play the selected video
    play(url.toString(),ui->widget_57->winId());
    //    // Play the video
    //    pPlaye->play();
    // 在控件 ui->listWidget 中查找并选中值为指定值的行
    QString valueToFind =url.toString();
    Qt::MatchFlags flags = Qt::MatchExactly; // 精确匹配标志
    QList<QListWidgetItem *> foundItems = ui->listWidget->findItems(valueToFind.replace(0, 1, valueToFind.at(0).toUpper()), flags);
    // 遍历找到的项
    for (QListWidgetItem* item : foundItems) {
        // 处理找到的项
        // 例如，访问项的文本或其他属性
        QString itemText = item->text();
        qDebug() << itemText;
        ui->listWidget->setCurrentItem(item);
    }
}

void MainWindow::on_pushButton_21_clicked()
{
    pPlaylist1->clear();
    foreach (const QTableWidgetSelectionRange &range, ui->tableWidget_2->selectedRanges()) {
        for(int i= range.topRow();i<=range.bottomRow();++i){
            qDebug()<<i;
            qDebug() << config.filelist[i].sourceFilePath;
            QUrl url( config.filelist[i].sourceFilePath);
            QStringList videoFormats = {"mp4", "avi", "mkv", "mov"};
            QString fileExtension = url.fileName().section('.', -1);
            if (videoFormats.contains(fileExtension, Qt::CaseInsensitive)) { // 判断是否为视频
                pPlaylist1->addMedia(url); // 加入到播放列表中
            }
        }
    }
    QMediaContent media = pPlaylist1->media(0); // Get the media item at the specified index
    QUrl url = media.request().url(); // Get the URL of the media item
    qDebug() <<url;
    //调用进程处理，暂停视频按钮
    this->process->write("quit\n");
    // Play the selected video
    qDebug() << "3"<<url;
    play(url.toString(),ui->widget_58->winId());
}

void MainWindow::on_pushButton_22_clicked()
{
    //调用进程处理，暂停视频按钮
    this->process->write("quit\n");
}
void MainWindow::on_photograph_clicked()
{
    // 创建文件夹
    QString logFolderPath = QString("/www/pic");
    if (!QDir(logFolderPath).exists()) {
        QDir().mkdir(logFolderPath);
    }
    //获取当前时间
    QDateTime Time(QDateTime::currentDateTime());
    //当前时间转变为文本格式
    QString datetime = Time.toString("yyyy-MM-dd-hh-mm-ss");
    //组装文件名（路径+名称）
    QString filename = QString("/www/pic/%1.jpg").arg(datetime);
    // 构造fswebcam命令
    QString fswebcamCommand = "fswebcam";
    QStringList fswebcamArguments;
    fswebcamArguments << "-r" << "1920x1080" << "--delay" << "3" << "--skip" << "30" << filename;
    // 创建QProcess对象并执行命令


    QProcess fswebcamProcess;
    fswebcamProcess.start(fswebcamCommand, fswebcamArguments);
    fswebcamProcess.waitForFinished();
    // 输出执行结果
    qDebug() << fswebcamProcess.readAllStandardOutput();
    qDebug() << fswebcamProcess.readAllStandardError();
}

void MainWindow::on_pushButton_skip_clicked()
{
    QJsonObject jsonObject;
    Send(ACQUISITION_STATION,POLICE_SITUATION_SKIP_C,jsonObject);
}
//void MainWindow::on_label_WOKIcon_Clicked()
//{
//    // 在这里添加显示具体内容的代码
//    // 例如，更新一个文本编辑框或显示一个对话框等
//    IP="";
//    IP=getNetworkIP();
//    QString content = QString("IP: %1").arg(IP);
//    QString sender = QString("MAC: %2").arg(mac);

//    QString htmlContent = QString("<p align='justify'>%1</p><p align='right'>%2").arg(content, sender);

//    QMessageBox::information(this, tr("网络信息"), htmlContent);
//}
// 当需要弹出选择框时，调用此函数
void MainWindow::showCancelImportDialog(int SerialportNum) {
    QMessageBox msgBox;
    msgBox.setText("确定要取消导入吗？");
    msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);

    msgBox.button(QMessageBox::Ok)->setText(tr("确定"));
    msgBox.button(QMessageBox::Cancel)->setText("取消");
    int ret = msgBox.exec();

    if (ret == QMessageBox::Ok) {
        // 用户点击确定，执行以下代码
        QJsonObject fgjsonObject;
        fgjsonObject["SerialportNum"] = SerialportNum;
        // 可以在这里向fgjsonObject添加数据，如果需要的话
        Send(ACQUISITION_STATION, CANCEL_UPLOAD, fgjsonObject);
    } else {
        // 用户点击取消，不执行任何操作或执行其他操作
    }
}

void MainWindow::on_pushButton_2111_clicked()
{
    // 获取屏幕的宽度
    int screenWidth = QApplication::desktop()->screenGeometry().width();

    int screenheight = QApplication::desktop()->screenGeometry().height();
    // 获取屏幕的宽度
    qDebug()<<screenWidth;
    qDebug()<<screenheight;
    ui->widget_121->setMinimumSize((screenWidth-80)/5,(screenheight-160)/5);
    ui->widget_121->setMaximumSize((screenWidth-80)/5,(screenheight-160)/5);
    ui->widget_122->setMinimumSize((screenWidth-80)/5,(screenheight-160)/5);
    ui->widget_122->setMaximumSize((screenWidth-80)/5,(screenheight-160)/5);
    ui->widget_123->setMinimumSize((screenWidth-80)/5,(screenheight-160)/5);
    ui->widget_123->setMaximumSize((screenWidth-80)/5,(screenheight-160)/5);
    ui->widget_124->setMinimumSize((screenWidth-80)/5,(screenheight-160)/5);
    ui->widget_124->setMaximumSize((screenWidth-80)/5,(screenheight-160)/5);
    ui->widget_125->setMinimumSize((screenWidth-80)/5,(screenheight-160)/5);
    ui->widget_125->setMaximumSize((screenWidth-80)/5,(screenheight-160)/5);
    ui->widget_126->setMinimumSize((screenWidth-80)/5,(screenheight-160)/5);
    ui->widget_126->setMaximumSize((screenWidth-80)/5,(screenheight-160)/5);
    ui->widget_127->setMinimumSize((screenWidth-80)/5,(screenheight-160)/5);
    ui->widget_127->setMaximumSize((screenWidth-80)/5,(screenheight-160)/5);
    ui->widget_128->setMinimumSize((screenWidth-80)/5,(screenheight-160)/5);
    ui->widget_128->setMaximumSize((screenWidth-80)/5,(screenheight-160)/5);
    ui->widget_129->setMinimumSize((screenWidth-80)/5,(screenheight-160)/5);
    ui->widget_129->setMaximumSize((screenWidth-80)/5,(screenheight-160)/5);
    ui->widget_130->setMinimumSize((screenWidth-80)/5,(screenheight-160)/5);
    ui->widget_130->setMaximumSize((screenWidth-80)/5,(screenheight-160)/5);
    ui->widget_131->setMinimumSize((screenWidth-80)/5,(screenheight-160)/5);
    ui->widget_131->setMaximumSize((screenWidth-80)/5,(screenheight-160)/5);
    ui->widget_132->setMinimumSize((screenWidth-80)/5,(screenheight-160)/5);
    ui->widget_132->setMaximumSize((screenWidth-80)/5,(screenheight-160)/5);
    ui->widget_133->setMinimumSize((screenWidth-80)/5,(screenheight-160)/5);
    ui->widget_133->setMaximumSize((screenWidth-80)/5,(screenheight-160)/5);
    ui->widget_134->setMinimumSize((screenWidth-80)/5,(screenheight-160)/5);
    ui->widget_134->setMaximumSize((screenWidth-80)/5,(screenheight-160)/5);
    ui->widget_135->setMinimumSize((screenWidth-80)/5,(screenheight-160)/5);
    ui->widget_135->setMaximumSize((screenWidth-80)/5,(screenheight-160)/5);
    ui->widget_136->setMinimumSize((screenWidth-80)/5,(screenheight-160)/5);
    ui->widget_136->setMaximumSize((screenWidth-80)/5,(screenheight-160)/5);
    ui->widget_137->setMinimumSize((screenWidth-80)/5,(screenheight-160)/5);
    ui->widget_137->setMaximumSize((screenWidth-80)/5,(screenheight-160)/5);
    ui->widget_138->setMinimumSize((screenWidth-80)/5,(screenheight-160)/5);
    ui->widget_138->setMaximumSize((screenWidth-80)/5,(screenheight-160)/5);
    ui->widget_139->setMinimumSize((screenWidth-80)/5,(screenheight-160)/5);
    ui->widget_139->setMaximumSize((screenWidth-80)/5,(screenheight-160)/5);
    ui->widget_140->setMinimumSize((screenWidth-80)/5,(screenheight-160)/5);
    ui->widget_140->setMaximumSize((screenWidth-80)/5,(screenheight-160)/5);
    ui->widget_141->setMinimumSize((screenWidth-80)/5,(screenheight-160)/5);
    ui->widget_141->setMaximumSize((screenWidth-80)/5,(screenheight-160)/5);
    ui->widget_142->setMinimumSize((screenWidth-80)/5,(screenheight-160)/5);
    ui->widget_142->setMaximumSize((screenWidth-80)/5,(screenheight-160)/5);
    ui->widget_143->setMinimumSize((screenWidth-80)/5,(screenheight-160)/5);
    ui->widget_143->setMaximumSize((screenWidth-80)/5,(screenheight-160)/5);
    ui->widget_144->setMinimumSize((screenWidth-80)/5,(screenheight-160)/5);
    ui->widget_144->setMaximumSize((screenWidth-80)/5,(screenheight-160)/5);
    ui->widget_145->setMinimumSize((screenWidth-80)/5,(screenheight-160)/5);
    ui->widget_145->setMaximumSize((screenWidth-80)/5,(screenheight-160)/5);
}
void MainWindow::on_lineEdit_Clicked()
{
    //不会阻塞程序
    QString processName = QString("onboard");
    QProcess process;
    process.startDetached(processName);
}
void MainWindow::on_label_101_Clicked()
{
    ui->label_101->setEnabled(false);
    ui->label_101_1->setEnabled(false);
    ui->label_101_2->setEnabled(false);
    ui->label_101_3->setEnabled(false);
    // 在按钮点击事件开始时，将鼠标指针设置为等待状态
    QGuiApplication::setOverrideCursor(Qt::PointingHandCursor);
    // Lambda 表达式
    QTimer::singleShot(1000, this, [=](){
        int index=1;
        if(IsUdisk[index]!=""&&IsUpload[index]!=true)
        {
            QString UserID="",Password="";

            OpenLoginDialog(UserID,Password,IdentNumber[index],6,101);
        }
        else if(IsUdisk[index]!=""&&IsUpload[index])
        {
            showCancelImportDialog(index);
        }
        // 在事件处理完成后，将鼠标指针恢复为原始状态
        ui->label_101->setEnabled(true);
        ui->label_101_1->setEnabled(true);
        ui->label_101_2->setEnabled(true);
        ui->label_101_3->setEnabled(true);
        QGuiApplication::restoreOverrideCursor();
    });
    return;
}

void MainWindow::on_label_102_Clicked()
{
    ui->label_102->setEnabled(false);
    ui->label_102_1->setEnabled(false);
    ui->label_102_2->setEnabled(false);
    ui->label_102_3->setEnabled(false);
    // 在按钮点击事件开始时，将鼠标指针设置为等待状态
    QGuiApplication::setOverrideCursor(Qt::PointingHandCursor);
    // Lambda 表达式
    QTimer::singleShot(1000, this, [=](){
        int index=2;
        if(IsUdisk[index]!=""&&IsUpload[index]!=true)
        {
            QString UserID="",Password="";

            OpenLoginDialog(UserID,Password,IdentNumber[index],6,102);
        }
        else if(IsUdisk[index]!=""&&IsUpload[index])
        {
            showCancelImportDialog(index);
        }
        // 在事件处理完成后，将鼠标指针恢复为原始状态
        ui->label_102->setEnabled(true);
        ui->label_102_1->setEnabled(true);
        ui->label_102_2->setEnabled(true);
        ui->label_102_3->setEnabled(true);
        QGuiApplication::restoreOverrideCursor();
    });
    return;
}
void MainWindow::on_label_103_Clicked()
{
    ui->label_103->setEnabled(false);
    ui->label_103_1->setEnabled(false);
    ui->label_103_2->setEnabled(false);
    ui->label_103_3->setEnabled(false);
    // 在按钮点击事件开始时，将鼠标指针设置为等待状态
    QGuiApplication::setOverrideCursor(Qt::PointingHandCursor);
    // Lambda 表达式
    QTimer::singleShot(1000, this, [=](){
        int index=3;
        if(IsUdisk[index]!=""&&IsUpload[index]!=true)
        {
            QString UserID="",Password="";

            OpenLoginDialog(UserID,Password,IdentNumber[index],6,103);
        }
        else if(IsUdisk[index]!=""&&IsUpload[index])
        {
            showCancelImportDialog(index);
        }
        // 在事件处理完成后，将鼠标指针恢复为原始状态
        ui->label_103->setEnabled(true);
        ui->label_103_1->setEnabled(true);
        ui->label_103_2->setEnabled(true);
        ui->label_103_3->setEnabled(true);
        QGuiApplication::restoreOverrideCursor();
    });
    return;
}
void MainWindow::on_label_104_Clicked()
{
    ui->label_104->setEnabled(false);
    ui->label_104_1->setEnabled(false);
    ui->label_104_2->setEnabled(false);
    ui->label_104_3->setEnabled(false);
    // 在按钮点击事件开始时，将鼠标指针设置为等待状态
    QGuiApplication::setOverrideCursor(Qt::PointingHandCursor);
    // Lambda 表达式
    QTimer::singleShot(1000, this, [=](){
        int index=4;
        if(IsUdisk[index]!=""&&IsUpload[index]!=true)
        {
            QString UserID="",Password="";

            OpenLoginDialog(UserID,Password,IdentNumber[index],6,104);
        } else if(IsUdisk[index]!=""&&IsUpload[index])
        {
            showCancelImportDialog(index);
        }
        // 在事件处理完成后，将鼠标指针恢复为原始状态
        ui->label_104->setEnabled(true);
        ui->label_104_1->setEnabled(true);
        ui->label_104_2->setEnabled(true);
        ui->label_104_3->setEnabled(true);
        QGuiApplication::restoreOverrideCursor();
    });
    return;
}
void MainWindow::on_label_105_Clicked()
{
    ui->label_105->setEnabled(false);
    ui->label_105_1->setEnabled(false);
    ui->label_105_2->setEnabled(false);
    ui->label_105_3->setEnabled(false);
    // 在按钮点击事件开始时，将鼠标指针设置为等待状态
    QGuiApplication::setOverrideCursor(Qt::PointingHandCursor);
    // Lambda 表达式
    QTimer::singleShot(1000, this, [=](){

        int index=5;
        if(IsUdisk[index]!=""&&IsUpload[index]!=true)
        {
            QString UserID="",Password="";

            OpenLoginDialog(UserID,Password,IdentNumber[index],6,105);
        } else if(IsUdisk[index]!=""&&IsUpload[index])
        {
            showCancelImportDialog(index);
        }
        // 在事件处理完成后，将鼠标指针恢复为原始状态
        ui->label_105->setEnabled(true);
        ui->label_105_1->setEnabled(true);
        ui->label_105_2->setEnabled(true);
        ui->label_105_3->setEnabled(true);
        QGuiApplication::restoreOverrideCursor();
    });
    return;
}
void MainWindow::on_label_106_Clicked()
{

    ui->label_106->setEnabled(false);
    ui->label_106_1->setEnabled(false);
    ui->label_106_2->setEnabled(false);
    ui->label_106_3->setEnabled(false);
    // 在按钮点击事件开始时，将鼠标指针设置为等待状态
    QGuiApplication::setOverrideCursor(Qt::PointingHandCursor);
    // Lambda 表达式
    QTimer::singleShot(1000, this, [=](){
        int index=6;
        if(IsUdisk[index]!=""&&IsUpload[index]!=true)
        {
            QString UserID="",Password="";

            OpenLoginDialog(UserID,Password,IdentNumber[index],6,106);
        } else if(IsUdisk[index]!=""&&IsUpload[index])
        {
            showCancelImportDialog(index);
        }
        // 在事件处理完成后，将鼠标指针恢复为原始状态
        ui->label_106->setEnabled(true);
        ui->label_106_1->setEnabled(true);
        ui->label_106_2->setEnabled(true);
        ui->label_106_3->setEnabled(true);
        QGuiApplication::restoreOverrideCursor();
    });
    return;
}
void MainWindow::on_label_107_Clicked()
{

    ui->label_107->setEnabled(false);
    ui->label_107_1->setEnabled(false);
    ui->label_107_2->setEnabled(false);
    ui->label_107_3->setEnabled(false);
    // 在按钮点击事件开始时，将鼠标指针设置为等待状态
    QGuiApplication::setOverrideCursor(Qt::PointingHandCursor);
    // Lambda 表达式
    QTimer::singleShot(1000, this, [=](){
        int index=7;
        if(IsUdisk[index]!=""&&IsUpload[index]!=true)
        {
            QString UserID="",Password="";

            OpenLoginDialog(UserID,Password,IdentNumber[index],6,107);
        } else if(IsUdisk[index]!=""&&IsUpload[index])
        {
            showCancelImportDialog(index);
        }
        // 在事件处理完成后，将鼠标指针恢复为原始状态
        ui->label_107->setEnabled(true);
        ui->label_107_1->setEnabled(true);
        ui->label_107_2->setEnabled(true);
        ui->label_107_3->setEnabled(true);
        QGuiApplication::restoreOverrideCursor();
    });
    return;
}
void MainWindow::on_label_108_Clicked()
{

    ui->label_108->setEnabled(false);
    ui->label_108_1->setEnabled(false);
    ui->label_108_2->setEnabled(false);
    ui->label_108_3->setEnabled(false);
    // 在按钮点击事件开始时，将鼠标指针设置为等待状态
    QGuiApplication::setOverrideCursor(Qt::PointingHandCursor);
    // Lambda 表达式
    QTimer::singleShot(1000, this, [=](){
        int index=8;
        if(IsUdisk[index]!=""&&IsUpload[index]!=true)
        {
            QString UserID="",Password="";

            OpenLoginDialog(UserID,Password,IdentNumber[index],6,108);
        } else if(IsUdisk[index]!=""&&IsUpload[index])
        {
            showCancelImportDialog(index);
        }
        // 在事件处理完成后，将鼠标指针恢复为原始状态
        ui->label_108->setEnabled(true);
        ui->label_108_1->setEnabled(true);
        ui->label_108_2->setEnabled(true);
        ui->label_108_3->setEnabled(true);
        QGuiApplication::restoreOverrideCursor();
    });
    return;
}
void MainWindow::on_label_109_Clicked()
{
    ui->label_109->setEnabled(false);
    ui->label_109_1->setEnabled(false);
    ui->label_109_2->setEnabled(false);
    ui->label_109_3->setEnabled(false);
    // 在按钮点击事件开始时，将鼠标指针设置为等待状态
    QGuiApplication::setOverrideCursor(Qt::PointingHandCursor);
    // Lambda 表达式
    QTimer::singleShot(1000, this, [=](){
        int index=9;
        if(IsUdisk[index]!=""&&IsUpload[index]!=true)
        {
            QString UserID="",Password="";

            OpenLoginDialog(UserID,Password,IdentNumber[index],6,109);
        } else if(IsUdisk[index]!=""&&IsUpload[index])
        {
            showCancelImportDialog(index);
        }
        // 在事件处理完成后，将鼠标指针恢复为原始状态
        ui->label_109->setEnabled(true);
        ui->label_109_1->setEnabled(true);
        ui->label_109_2->setEnabled(true);
        ui->label_109_3->setEnabled(true);
        QGuiApplication::restoreOverrideCursor();
    });
    return;
}
void MainWindow::on_label_110_Clicked()
{
    ui->label_110->setEnabled(false);
    ui->label_110_1->setEnabled(false);
    ui->label_110_2->setEnabled(false);
    ui->label_110_3->setEnabled(false);
    // 在按钮点击事件开始时，将鼠标指针设置为等待状态
    QGuiApplication::setOverrideCursor(Qt::PointingHandCursor);
    // Lambda 表达式
    QTimer::singleShot(1000, this, [=](){
        int index=10;
        if(IsUdisk[index]!=""&&IsUpload[index]!=true)
        {
            QString UserID="",Password="";

            OpenLoginDialog(UserID,Password,IdentNumber[index],6,110);
        } else if(IsUdisk[index]!=""&&IsUpload[index])
        {
            showCancelImportDialog(index);
        }
        // 在事件处理完成后，将鼠标指针恢复为原始状态
        ui->label_110->setEnabled(true);
        ui->label_110_1->setEnabled(true);
        ui->label_110_2->setEnabled(true);
        ui->label_110_3->setEnabled(true);
        QGuiApplication::restoreOverrideCursor();
    });
    return;
}
void MainWindow::on_label_111_Clicked()
{
    ui->label_111->setEnabled(false);
    ui->label_111_1->setEnabled(false);
    ui->label_111_2->setEnabled(false);
    ui->label_111_3->setEnabled(false);
    // 在按钮点击事件开始时，将鼠标指针设置为等待状态
    QGuiApplication::setOverrideCursor(Qt::PointingHandCursor);
    // Lambda 表达式
    QTimer::singleShot(1000, this, [=](){
        int index=11;
        if(IsUdisk[index]!=""&&IsUpload[index]!=true)
        {
            QString UserID="",Password="";

            OpenLoginDialog(UserID,Password,IdentNumber[index],6,111);
        }
        else if(IsUdisk[index]!=""&&IsUpload[index])
        {
            showCancelImportDialog(index);
        }
        // 在事件处理完成后，将鼠标指针恢复为原始状态
        ui->label_111->setEnabled(true);
        ui->label_111_1->setEnabled(true);
        ui->label_111_2->setEnabled(true);
        ui->label_111_3->setEnabled(true);
        QGuiApplication::restoreOverrideCursor();
    });
    return;
}
void MainWindow::on_label_112_Clicked()
{
    ui->label_112->setEnabled(false);
    ui->label_112_1->setEnabled(false);
    ui->label_112_2->setEnabled(false);
    ui->label_112_3->setEnabled(false);
    // 在按钮点击事件开始时，将鼠标指针设置为等待状态
    QGuiApplication::setOverrideCursor(Qt::PointingHandCursor);
    // Lambda 表达式
    QTimer::singleShot(1000, this, [=](){
        int index=12;
        if(IsUdisk[index]!=""&&IsUpload[index]!=true)
        {
            QString UserID="",Password="";

            OpenLoginDialog(UserID,Password,IdentNumber[index],6,112);
        } else if(IsUdisk[index]!=""&&IsUpload[index])
        {
            showCancelImportDialog(index);
        }
        // 在事件处理完成后，将鼠标指针恢复为原始状态
        ui->label_112->setEnabled(true);
        ui->label_112_1->setEnabled(true);
        ui->label_112_2->setEnabled(true);
        ui->label_112_3->setEnabled(true);
        QGuiApplication::restoreOverrideCursor();
    });
    return;
}
void MainWindow::on_label_113_Clicked()
{
    ui->label_113->setEnabled(false);
    ui->label_113_1->setEnabled(false);
    ui->label_113_2->setEnabled(false);
    ui->label_113_3->setEnabled(false);
    // 在按钮点击事件开始时，将鼠标指针设置为等待状态
    QGuiApplication::setOverrideCursor(Qt::PointingHandCursor);
    // Lambda 表达式
    QTimer::singleShot(1000, this, [=](){
        int index=13;
        if(IsUdisk[index]!=""&&IsUpload[index]!=true)
        {
            QString UserID="",Password="";

            OpenLoginDialog(UserID,Password,IdentNumber[index],6,113);
        } else if(IsUdisk[index]!=""&&IsUpload[index])
        {
            showCancelImportDialog(index);
        }
        // 在事件处理完成后，将鼠标指针恢复为原始状态
        ui->label_113->setEnabled(true);
        ui->label_113_1->setEnabled(true);
        ui->label_113_2->setEnabled(true);
        ui->label_113_3->setEnabled(true);
        QGuiApplication::restoreOverrideCursor();
    });
    return;
}
void MainWindow::on_label_114_Clicked()
{
    ui->label_114->setEnabled(false);
    ui->label_114_1->setEnabled(false);
    ui->label_114_2->setEnabled(false);
    ui->label_114_3->setEnabled(false);
    // 在按钮点击事件开始时，将鼠标指针设置为等待状态
    QGuiApplication::setOverrideCursor(Qt::PointingHandCursor);
    // Lambda 表达式
    QTimer::singleShot(1000, this, [=](){
        int index=14;
        if(IsUdisk[index]!=""&&IsUpload[index]!=true)
        {
            QString UserID="",Password="";

            OpenLoginDialog(UserID,Password,IdentNumber[index],6,114);
        } else if(IsUdisk[index]!=""&&IsUpload[index])
        {
            showCancelImportDialog(index);
        }
        // 在事件处理完成后，将鼠标指针恢复为原始状态
        ui->label_114->setEnabled(true);
        ui->label_114_1->setEnabled(true);
        ui->label_114_2->setEnabled(true);
        ui->label_114_3->setEnabled(true);
        QGuiApplication::restoreOverrideCursor();
    });
    return;
}
void MainWindow::on_label_115_Clicked()
{
    ui->label_115->setEnabled(false);
    ui->label_115_1->setEnabled(false);
    ui->label_115_2->setEnabled(false);
    ui->label_115_3->setEnabled(false);
    // 在按钮点击事件开始时，将鼠标指针设置为等待状态
    QGuiApplication::setOverrideCursor(Qt::PointingHandCursor);
    // Lambda 表达式
    QTimer::singleShot(1000, this, [=](){
        int index=15;
        if(IsUdisk[index]!=""&&IsUpload[index]!=true)
        {
            QString UserID="",Password="";

            OpenLoginDialog(UserID,Password,IdentNumber[index],6,115);
        } else if(IsUdisk[index]!=""&&IsUpload[index])
        {
            showCancelImportDialog(index);
        }
        // 在事件处理完成后，将鼠标指针恢复为原始状态
        ui->label_115->setEnabled(true);
        ui->label_115_1->setEnabled(true);
        ui->label_115_2->setEnabled(true);
        ui->label_115_3->setEnabled(true);
        QGuiApplication::restoreOverrideCursor();
    });
    return;
}
void MainWindow::on_label_116_Clicked()
{
    ui->label_116->setEnabled(false);
    ui->label_116_1->setEnabled(false);
    ui->label_116_2->setEnabled(false);
    ui->label_116_3->setEnabled(false);
    // 在按钮点击事件开始时，将鼠标指针设置为等待状态
    QGuiApplication::setOverrideCursor(Qt::PointingHandCursor);
    // Lambda 表达式
    QTimer::singleShot(1000, this, [=](){
        int index=16;
        if(IsUdisk[index]!=""&&IsUpload[index]!=true)
        {
            QString UserID="",Password="";

            OpenLoginDialog(UserID,Password,IdentNumber[index],6,116);
        } else if(IsUdisk[index]!=""&&IsUpload[index])
        {
            showCancelImportDialog(index);
        }
        // 在事件处理完成后，将鼠标指针恢复为原始状态
        ui->label_116->setEnabled(true);
        ui->label_116_1->setEnabled(true);
        ui->label_116_2->setEnabled(true);
        ui->label_116_3->setEnabled(true);
        QGuiApplication::restoreOverrideCursor();
    });
    return;
}
void MainWindow::on_label_117_Clicked()
{
    ui->label_117->setEnabled(false);
    ui->label_117_1->setEnabled(false);
    ui->label_117_2->setEnabled(false);
    ui->label_117_3->setEnabled(false);
    // 在按钮点击事件开始时，将鼠标指针设置为等待状态
    QGuiApplication::setOverrideCursor(Qt::PointingHandCursor);
    // Lambda 表达式
    QTimer::singleShot(1000, this, [=](){
        int index=17;
        if(IsUdisk[index]!=""&&IsUpload[index]!=true)
        {
            QString UserID="",Password="";

            OpenLoginDialog(UserID,Password,IdentNumber[index],6,117);
        } else if(IsUdisk[index]!=""&&IsUpload[index])
        {
            showCancelImportDialog(index);
        }
        // 在事件处理完成后，将鼠标指针恢复为原始状态
        ui->label_117->setEnabled(true);
        ui->label_117_1->setEnabled(true);
        ui->label_117_2->setEnabled(true);
        ui->label_117_3->setEnabled(true);
        QGuiApplication::restoreOverrideCursor();
    });
    return;
}
void MainWindow::on_label_118_Clicked()
{
    ui->label_118->setEnabled(false);
    ui->label_118_1->setEnabled(false);
    ui->label_118_2->setEnabled(false);
    ui->label_118_3->setEnabled(false);
    // 在按钮点击事件开始时，将鼠标指针设置为等待状态
    QGuiApplication::setOverrideCursor(Qt::PointingHandCursor);
    // Lambda 表达式
    QTimer::singleShot(1000, this, [=](){
        int index=18;
        if(IsUdisk[index]!=""&&IsUpload[index]!=true)
        {
            QString UserID="",Password="";

            OpenLoginDialog(UserID,Password,IdentNumber[index],6,118);
        } else if(IsUdisk[index]!=""&&IsUpload[index])
        {
            showCancelImportDialog(index);
        }
        // 在事件处理完成后，将鼠标指针恢复为原始状态
        ui->label_118->setEnabled(true);
        ui->label_118_1->setEnabled(true);
        ui->label_118_2->setEnabled(true);
        ui->label_118_3->setEnabled(true);
        QGuiApplication::restoreOverrideCursor();
    });
    return;
}
void MainWindow::on_label_119_Clicked()
{
    ui->label_119->setEnabled(false);
    ui->label_119_1->setEnabled(false);
    ui->label_119_2->setEnabled(false);
    ui->label_119_3->setEnabled(false);
    // 在按钮点击事件开始时，将鼠标指针设置为等待状态
    QGuiApplication::setOverrideCursor(Qt::PointingHandCursor);
    // Lambda 表达式
    QTimer::singleShot(1000, this, [=](){
        int index=19;
        if(IsUdisk[index]!=""&&IsUpload[index]!=true)
        {
            QString UserID="",Password="";

            OpenLoginDialog(UserID,Password,IdentNumber[index],6,119);
        } else if(IsUdisk[index]!=""&&IsUpload[index])
        {
            showCancelImportDialog(index);
        }
        // 在事件处理完成后，将鼠标指针恢复为原始状态
        ui->label_119->setEnabled(true);
        ui->label_119_1->setEnabled(true);
        ui->label_119_2->setEnabled(true);
        ui->label_119_3->setEnabled(true);
        QGuiApplication::restoreOverrideCursor();
    });
    return;
}
void MainWindow::on_label_120_Clicked()
{
    ui->label_120->setEnabled(false);
    ui->label_120_1->setEnabled(false);
    ui->label_120_2->setEnabled(false);
    ui->label_120_3->setEnabled(false);
    // 在按钮点击事件开始时，将鼠标指针设置为等待状态
    QGuiApplication::setOverrideCursor(Qt::PointingHandCursor);
    // Lambda 表达式
    QTimer::singleShot(1000, this, [=](){
        int index=20;
        if(IsUdisk[index]!=""&&IsUpload[index]!=true)
        {
            QString UserID="",Password="";

            OpenLoginDialog(UserID,Password,IdentNumber[index],6,120);
        } else if(IsUdisk[index]!=""&&IsUpload[index])
        {
            showCancelImportDialog(index);
        }
        // 在事件处理完成后，将鼠标指针恢复为原始状态
        ui->label_120->setEnabled(true);
        ui->label_120_1->setEnabled(true);
        ui->label_120_2->setEnabled(true);
        ui->label_120_3->setEnabled(true);
        QGuiApplication::restoreOverrideCursor();
    });
    return;
}
void MainWindow::on_label_121_Clicked()
{
    ui->label_121->setEnabled(false);
    ui->label_121_1->setEnabled(false);
    ui->label_121_2->setEnabled(false);
    ui->label_121_3->setEnabled(false);
    // 在按钮点击事件开始时，将鼠标指针设置为等待状态
    QGuiApplication::setOverrideCursor(Qt::PointingHandCursor);
    // Lambda 表达式
    QTimer::singleShot(1000, this, [=](){
        int index=21;
        if(IsUdisk[index]!=""&&IsUpload[index]!=true)
        {
            QString UserID="",Password="";

            OpenLoginDialog(UserID,Password,IdentNumber[index],6,121);
        } else if(IsUdisk[index]!=""&&IsUpload[index])
        {
            showCancelImportDialog(index);
        }
        // 在事件处理完成后，将鼠标指针恢复为原始状态
        ui->label_121->setEnabled(true);
        ui->label_121_1->setEnabled(true);
        ui->label_121_2->setEnabled(true);
        ui->label_121_3->setEnabled(true);
        QGuiApplication::restoreOverrideCursor();
    });
    return;
}
void MainWindow::on_label_122_Clicked()
{
    ui->label_122->setEnabled(false);
    ui->label_122_1->setEnabled(false);
    ui->label_122_2->setEnabled(false);
    ui->label_122_3->setEnabled(false);
    // 在按钮点击事件开始时，将鼠标指针设置为等待状态
    QGuiApplication::setOverrideCursor(Qt::PointingHandCursor);
    // Lambda 表达式
    QTimer::singleShot(1000, this, [=](){
        int index=22;
        if(IsUdisk[index]!=""&&IsUpload[index]!=true)
        {
            QString UserID="",Password="";

            OpenLoginDialog(UserID,Password,IdentNumber[index],6,122);
        }  else if(IsUdisk[index]!=""&&IsUpload[index])
        {
            showCancelImportDialog(index);
        }// 在事件处理完成后，将鼠标指针恢复为原始状态
        ui->label_122->setEnabled(true);
        ui->label_122_1->setEnabled(true);
        ui->label_122_2->setEnabled(true);
        ui->label_122_3->setEnabled(true);
        QGuiApplication::restoreOverrideCursor();
    });
    return;
}
void MainWindow::on_label_123_Clicked()
{
    ui->label_123->setEnabled(false);
    ui->label_123_1->setEnabled(false);
    ui->label_123_2->setEnabled(false);
    ui->label_123_3->setEnabled(false);
    // 在按钮点击事件开始时，将鼠标指针设置为等待状态
    QGuiApplication::setOverrideCursor(Qt::PointingHandCursor);
    // Lambda 表达式
    QTimer::singleShot(1000, this, [=](){
        int index=23;
        if(IsUdisk[index]!=""&&IsUpload[index]!=true)
        {
            QString UserID="",Password="";

            OpenLoginDialog(UserID,Password,IdentNumber[index],6,123);
        } else if(IsUdisk[index]!=""&&IsUpload[index])
        {
            showCancelImportDialog(index);
        }
        ui->label_123->setEnabled(true);
        ui->label_123_1->setEnabled(true);
        ui->label_123_2->setEnabled(true);
        ui->label_123_3->setEnabled(true);
        QGuiApplication::restoreOverrideCursor();
    });
    return;
}
void MainWindow::on_label_124_Clicked()
{
    ui->label_124->setEnabled(false);
    ui->label_124_1->setEnabled(false);
    ui->label_124_2->setEnabled(false);
    ui->label_124_3->setEnabled(false);
    // 在按钮点击事件开始时，将鼠标指针设置为等待状态
    QGuiApplication::setOverrideCursor(Qt::PointingHandCursor);
    // Lambda 表达式
    QTimer::singleShot(1000, this, [=](){
        int index=24;
        if(IsUdisk[index]!=""&&IsUpload[index]!=true)
        {
            QString UserID="",Password="";

            OpenLoginDialog(UserID,Password,IdentNumber[index],6,124);
        } else if(IsUdisk[index]!=""&&IsUpload[index])
        {
            showCancelImportDialog(index);
        }
        ui->label_124->setEnabled(true);
        ui->label_124_1->setEnabled(true);
        ui->label_124_2->setEnabled(true);
        ui->label_124_3->setEnabled(true);
        QGuiApplication::restoreOverrideCursor();
    });
    return;
}
void MainWindow::on_label_125_Clicked()
{
    ui->label_125->setEnabled(false);
    ui->label_125_1->setEnabled(false);
    ui->label_125_2->setEnabled(false);
    ui->label_125_3->setEnabled(false);
    // 在按钮点击事件开始时，将鼠标指针设置为等待状态
    QGuiApplication::setOverrideCursor(Qt::PointingHandCursor);
    // Lambda 表达式
    QTimer::singleShot(1000, this, [=](){
        int index=25;
        if(IsUdisk[index]!=""&&IsUpload[index]!=true)
        {
            QString UserID="",Password="";

            OpenLoginDialog(UserID,Password,IdentNumber[index],6,125);
        } else if(IsUdisk[index]!=""&&IsUpload[index])
        {
            showCancelImportDialog(index);
        }
        ui->label_125->setEnabled(true);
        ui->label_125_1->setEnabled(true);
        ui->label_125_2->setEnabled(true);
        ui->label_125_3->setEnabled(true);
        QGuiApplication::restoreOverrideCursor();
    });
    return;
}
void MainWindow::on_lineEdit_UserID_Clicked()
{
    //不会阻塞程序
    QString processName = QString("onboard");
    QProcess process;
    process.startDetached(processName);
}
void MainWindow::on_label_Clicked()
{
    QString UserID="";
    QString Password="";
    dialog.Open();
    if (dialog.exec() == QDialog::Accepted) {
        // 登录成功，执行相应操作
        //    //读取配置文件

        UserID=dialog.usernameLineEdit->text();
        Password=dialog.passwordLineEdit->text();
        if(UserID==""||Password=="")
        {
            QMessageBox::critical(nullptr,tr("错误"), tr("账号或密码不能为空"));
        }
        else
        {

            QJsonObject jsonObject;
            jsonObject["UserID"] = UserID;
            jsonObject["Password"] = Password;
            Send(ACQUISITION_STATION,LOCK_LABEL_C,jsonObject);
        }

    }
    dialog.Close();
    //dialog.Delete();
    return;
}
void MainWindow::on_textBrowser_Clicked()
{

    if(!IsNotic)
    {

        IsNotic=true;
        if(Notice.size()>0)
        {
            // 显示悬浮容器
            for(int i=0;i<Notice.size();i++)
            {
                //加入到Noticelist
                Noticelist.append(Notice[i].AnnouncementTitle); // Assuming Notice is a QStringList
                model->setStringList(Noticelist);
            }
            frame->show();
        }
        // frame->hide();
    }
    else
    {
        Noticelist.clear();
        IsNotic=false;
        frame->hide();
    }
    return;
}
void MainWindow::onItemClicked(const QModelIndex &index)
{
    // 获取点击的项的数据
    QString itemText = index.model()->data(index, Qt::DisplayRole).toString();

    for(int i=0;i<Notice.size();i++)
    {
        // 根据项的内容显示具体信息
        if (itemText == Notice[i].AnnouncementTitle) {
            // 在这里添加显示具体内容的代码
            // 例如，更新一个文本编辑框或显示一个对话框等
            QString content = QString("内容: %1").arg(Notice[i].AnnouncementContent);
            QString sender = QString("发送人: %2").arg(Notice[i].AnnouncementCc);
            QString time = QString("发送时间: %3").arg(Notice[i].AnnouncementTime);

            QString htmlContent = QString("<p align='justify'>%1</p><p align='right'>%2<br>%3</p>").arg(content, sender, time);

            QMessageBox::information(this, Notice[i].AnnouncementTitle, htmlContent);
        }
    }
    // 可以添加其他项的处理逻辑

}

void MainWindow::on_pushButton_111111_clicked()
{
    qDebug()<<"当前路径"<<currentPath;
    config.WriteInfo(QString("当前路径%1").arg(currentPath));
    QString processName = QString("%1\\Delete.sh").arg(currentPath);
    QProcess process;
    process.start(processName);
    process.waitForFinished(-1); // 等HOUT待进程完成
}

void MainWindow::on_pushButton_switch_clicked()
{
    QJsonObject jsonObject;
    \
    Send(ACQUISITION_STATION,INTERFACE_SWITCH_C,jsonObject);
}

void MainWindow::on_pushButton_fastforward_clicked()
{
    QString speedCommand = "speed 2\n";
    this->process->write(speedCommand.toUtf8());
}

void MainWindow::on_pushButton_PFrame_clicked()
{
    QString pauseCommand = "pause\n";
    this->process->write(pauseCommand.toUtf8());
    //可能需要等待一段时间以确保mplayer处理了pause命令
    QThread::sleep(1000); // 这只是一个示例，实际等待时间可能需要根据mplayer的行为来调整
    // qDebug()<<"on_pushButton_PFrame_clicked"<<Playposition;
    //    QString command=QString("seek %1 0\n").arg(50);
    //    this->process->write(command.toUtf8());
}

void MainWindow::on_horizontalSlider_valueChanged(int value)
{
    //     QProcess *mplayerProcess;
    //    QString mediaFile = "/tcl/sdv/Red5/admin/2340016_20241017145544/video/000000_20241010085639977_0154_TCL.mp4"; // 替换为你的视频文件路径

    //        QStringList arguments;
    //        arguments << mediaFile;

    //        mplayerProcess->start("mplayer", arguments);

    //        if (!mplayerProcess->waitForStarted()) {
    //            QMessageBox::critical(this, "Error", "Failed to start mplayer");
    //            //return;
    //        }
    //    qDebug()<<"valueChanged"<<value;
    //    Playposition=value;
    QString processName = QString("mplayer /tcl/sdv/Red5/admin/2340016_20241017145544/video/000000_20241010085639977_0154_TCL.mp4");
    QProcess process;
    process.start(processName);
    process.waitForFinished(-1); // 等HOUT待进程完成
    //    QString command=QString("seek %1 0\n").arg(value);
    //    this->process->write(command.toUtf8());
}

void MainWindow::on_pushButton_PreviousPhoto_clicked()
{QList<QListWidgetItem*> selectedItems = ui->listWidget->selectedItems();
    if (!selectedItems.isEmpty()) {
        foreach (QListWidgetItem* item, selectedItems) {
            int currentIndex = ui->listWidget->row(item);
            int itemCount = ui->listWidget->count();
            qDebug()<<"currentIndex"<<currentIndex;
            // for (int i = currentIndex + 1; i < itemCount; i++) {
            if(currentIndex-1>=0)
            {

                currentIndex-=1;
                QListWidgetItem* nextItem = ui->listWidget->item(currentIndex);
                QString nextPath = nextItem->text();
                viewer->setImage(nextPath);
                viewer->scale(1,1);
                ui->listWidget->setCurrentItem(nextItem);
            }
            else
            {
                currentIndex=itemCount-1;
                QListWidgetItem* nextItem = ui->listWidget->item(currentIndex);
                QString nextPath = nextItem->text();
                viewer->setImage(nextPath);
                viewer->scale(1,1);
                ui->listWidget->setCurrentItem(nextItem);
            }
        }
    }

}

void MainWindow::on_pushButton_NextPhoto_clicked()
{
    QList<QListWidgetItem*> selectedItems = ui->listWidget->selectedItems();
    if (!selectedItems.isEmpty()) {
        foreach (QListWidgetItem* item, selectedItems) {
            int currentIndex = ui->listWidget->row(item);
            int itemCount = ui->listWidget->count();
            qDebug()<<"currentIndex"<<currentIndex;
            // for (int i = currentIndex + 1; i < itemCount; i++) {
            if(currentIndex+1<itemCount)
            {
                currentIndex+=1;
                QListWidgetItem* nextItem = ui->listWidget->item(currentIndex);
                QString nextPath = nextItem->text();
                viewer->setImage(nextPath);
                viewer->scale(1,1);
                ui->listWidget->setCurrentItem(nextItem);
            }
            else
            {
                currentIndex=0;
                QListWidgetItem* nextItem = ui->listWidget->item(currentIndex);
                QString nextPath = nextItem->text();
                viewer->setImage(nextPath);
                viewer->scale(1,1);
                ui->listWidget->setCurrentItem(nextItem);
            }
        }
    }
}

void MainWindow::on_pushButton_OPEN_clicked()
{
    QString processName = QString("untitled1");
    QProcess process;
    process.startDetached(processName);

}

void MainWindow::on_pushButton_OpenAudio_clicked()
{
    QString processName = QString("untitled1");
    QProcess process;
    process.startDetached(processName);

}
